aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/aniso.c16
-rw-r--r--tests/cases/emptystruct.ll2
-rw-r--r--tests/cases/fp80_ta2.ll (renamed from tests/cases/fp80.ll)0
-rw-r--r--tests/cases/muli33_ta2.ll114
-rw-r--r--tests/cases/muli33_ta2.txt1
-rw-r--r--tests/cases/philoop_ta2.ll305
-rw-r--r--tests/cases/philoop_ta2.txt1
-rw-r--r--tests/files.cpp3
-rw-r--r--tests/full_es2_sdlproc.c727
-rw-r--r--tests/gl_ps.c40
-rw-r--r--tests/gl_ps_workaround.c230
-rw-r--r--tests/gl_ps_workaround2.c230
-rw-r--r--tests/glbegin_points.c44
-rw-r--r--tests/linpack.c1153
-rwxr-xr-xtests/runner.py553
-rw-r--r--tests/s3tc.c16
-rw-r--r--tests/s3tc_crunch.c16
-rw-r--r--tests/sdl_fog_density.c48
-rw-r--r--tests/sdl_fog_exp2.c48
-rw-r--r--tests/sdl_fog_linear.c48
-rw-r--r--tests/sdl_fog_negative.c48
-rw-r--r--tests/sdl_fog_simple.c51
-rw-r--r--tests/sdl_ogl.c48
-rw-r--r--tests/sdl_ogl_defaultMatrixMode.c46
-rw-r--r--tests/sdl_ogl_p.c44
25 files changed, 3019 insertions, 813 deletions
diff --git a/tests/aniso.c b/tests/aniso.c
index e02c20ac..1126265e 100644
--- a/tests/aniso.c
+++ b/tests/aniso.c
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
const char *exts = (const char *)glGetString(GL_EXTENSIONS);
assert(hasext(exts, "GL_EXT_texture_filter_anisotropic"));
-
+
GLint aniso;
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &aniso);
printf("Max anisotropy: %d (using that)\n", aniso);
@@ -73,10 +73,8 @@ int main(int argc, char *argv[])
// Set the OpenGL state after creating the context with SDL_SetVideoMode
glClearColor( 0, 0, 0, 0 );
-
-#if !EMSCRIPTEN
- glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL
-#endif
+
+ glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline.
glViewport( 0, 0, 600, 600 );
@@ -155,7 +153,7 @@ int main(int argc, char *argv[])
// Clear the screen before drawing
glClear( GL_COLOR_BUFFER_BIT );
-
+
// Bind the texture to which subsequent calls refer to
int w = 10;
int n = 15;
@@ -200,7 +198,7 @@ int main(int argc, char *argv[])
}
*/
SDL_GL_SwapBuffers();
-
+
#if !EMSCRIPTEN
// Wait for 3 seconds to give us a chance to see the image
SDL_Delay(2000);
@@ -208,8 +206,8 @@ int main(int argc, char *argv[])
// Now we can delete the OpenGL texture and close down SDL
glDeleteTextures( 1, &texture );
-
+
SDL_Quit();
-
+
return 0;
}
diff --git a/tests/cases/emptystruct.ll b/tests/cases/emptystruct.ll
index 67967e65..ecf0e295 100644
--- a/tests/cases/emptystruct.ll
+++ b/tests/cases/emptystruct.ll
@@ -6,6 +6,8 @@ target triple = "i386-pc-linux-gnu"
@.str = private constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1]
+@.waka = extern_weak global i8* ; no initializer!
+
define i32 @main() nounwind {
entry:
%z = alloca %struct.s, align 4
diff --git a/tests/cases/fp80.ll b/tests/cases/fp80_ta2.ll
index 7fc0db4a..7fc0db4a 100644
--- a/tests/cases/fp80.ll
+++ b/tests/cases/fp80_ta2.ll
diff --git a/tests/cases/muli33_ta2.ll b/tests/cases/muli33_ta2.ll
new file mode 100644
index 00000000..b33b04f7
--- /dev/null
+++ b/tests/cases/muli33_ta2.ll
@@ -0,0 +1,114 @@
+; ModuleID = '/tmp/tmpt0JpDh/a.out.bc'
+target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
+target triple = "le32-unknown-nacl"
+
+@.str = private unnamed_addr constant [7 x i8] c"20\0A91\0A\00", align 1
+@.str1 = private unnamed_addr constant [6 x i8] c"%u %u\00", align 1
+@.str2 = private unnamed_addr constant [10 x i8] c"res = %u\0A\00", align 1
+
+define i32 @main() nounwind {
+ %j = alloca i32, align 4
+ %k4 = alloca i32, align 4
+ %t = alloca [100 x [100 x i32]], align 4
+ store i32 20, i32* %j, align 4
+ store i32 91, i32* %k4, align 4
+ br label %.lr.ph.i
+
+.lr.ph.i: ; preds = %.lr.ph.i, %0
+ %j.07.i = phi i32 [ %7, %.lr.ph.i ], [ 0, %0 ]
+ %1 = and i32 %j.07.i, 1
+ %2 = icmp eq i32 %1, 0
+ %3 = sub i32 0, %j.07.i
+ %.p.i = select i1 %2, i32 %j.07.i, i32 %3
+ %4 = add i32 %.p.i, 8
+ %5 = urem i32 %4, 101
+ %6 = getelementptr inbounds [100 x [100 x i32]]* %t, i32 0, i32 0, i32 %j.07.i
+ store i32 %5, i32* %6, align 4
+ %7 = add i32 %j.07.i, 1
+ %8 = icmp ult i32 %7, 10000
+ br i1 %8, label %.lr.ph.i, label %init.exit
+
+init.exit: ; preds = %.lr.ph.i
+ %9 = call i32 (i8*, i8*, ...)* @sscanf(i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8]* @.str1, i32 0, i32 0), i32* %j, i32* %k4) nounwind
+ store i32 53, i32* %j, align 4
+ br label %.preheader
+
+.preheader: ; preds = %29, %init.exit
+ %indvars.iv23 = phi i32 [ -29, %init.exit ], [ %indvars.iv.next24, %29 ]
+ %indvars.iv21 = phi i32 [ -28, %init.exit ], [ %indvars.iv.next22, %29 ]
+ %indvars.iv19 = phi i32 [ -27, %init.exit ], [ %indvars.iv.next20, %29 ]
+ %indvars.iv17 = phi i32 [ 109, %init.exit ], [ %indvars.iv.next18, %29 ]
+ %indvars.iv15 = phi i32 [ -75923, %init.exit ], [ %indvars.iv.next16, %29 ]
+ %indvars.iv13 = phi i32 [ 5593, %init.exit ], [ %indvars.iv.next14, %29 ]
+ %indvars.iv = phi i32 [ -262, %init.exit ], [ %indvars.iv.next, %29 ]
+ %10 = phi i32 [ 53, %init.exit ], [ %.pre-phi, %29 ]
+ %11 = zext i32 %indvars.iv19 to i33
+ %12 = zext i32 %indvars.iv21 to i33
+ %13 = mul i33 %11, %12
+ %14 = icmp ult i32 %10, 27
+ br i1 %14, label %.lr.ph, label %.preheader._crit_edge
+
+.preheader._crit_edge: ; preds = %.preheader
+ %.pre = add i32 %10, -1
+ br label %29
+
+.lr.ph: ; preds = %.preheader
+ %15 = zext i32 %indvars.iv23 to i33
+ %16 = mul i33 %13, %15
+ %17 = lshr i33 %16, 1
+ %18 = lshr i33 %13, 1
+ %19 = trunc i33 %17 to i32
+ %20 = trunc i33 %18 to i32
+ %21 = mul i32 %19, 1431655766
+ %22 = mul i32 %indvars.iv17, %20
+ %23 = add i32 %10, -1
+ %24 = add i32 %10, 1
+ %25 = getelementptr inbounds [100 x [100 x i32]]* %t, i32 0, i32 %24, i32 %23
+ %.promoted = load i32* %25, align 4
+ %26 = add i32 %.promoted, %indvars.iv15
+ %27 = add i32 %26, %22
+ %28 = add i32 %27, %21
+ store i32 %28, i32* %25, align 4
+ br label %29
+
+.lr.ph.i3.preheader: ; preds = %29
+ store i32 2, i32* %j, align 4
+ store i32 %.lcssa69, i32* %k4, align 4
+ br label %.lr.ph.i3
+
+; <label>:29 ; preds = %.lr.ph, %.preheader._crit_edge
+ %.pre-phi = phi i32 [ %.pre, %.preheader._crit_edge ], [ %23, %.lr.ph ]
+ %.lcssa69 = phi i32 [ %10, %.preheader._crit_edge ], [ 27, %.lr.ph ]
+ %30 = icmp ugt i32 %.pre-phi, 2
+ %indvars.iv.next = add i32 %indvars.iv, 6
+ %indvars.iv.next14 = add i32 %indvars.iv13, %indvars.iv
+ %indvars.iv.next16 = add i32 %indvars.iv15, %indvars.iv13
+ %indvars.iv.next18 = add i32 %indvars.iv17, -2
+ %indvars.iv.next20 = add i32 %indvars.iv19, 1
+ %indvars.iv.next22 = add i32 %indvars.iv21, 1
+ %indvars.iv.next24 = add i32 %indvars.iv23, 1
+ br i1 %30, label %.preheader, label %.lr.ph.i3.preheader
+
+.lr.ph.i3: ; preds = %.lr.ph.i3, %.lr.ph.i3.preheader
+ %sum.07.i = phi i32 [ %37, %.lr.ph.i3 ], [ 0, %.lr.ph.i3.preheader ]
+ %j.06.i = phi i32 [ %38, %.lr.ph.i3 ], [ 0, %.lr.ph.i3.preheader ]
+ %31 = and i32 %j.06.i, 1
+ %32 = icmp eq i32 %31, 0
+ %33 = getelementptr inbounds [100 x [100 x i32]]* %t, i32 0, i32 0, i32 %j.06.i
+ %34 = load i32* %33, align 4
+ %35 = sub i32 0, %34
+ %36 = select i1 %32, i32 %34, i32 %35
+ %37 = add i32 %36, %sum.07.i
+ %38 = add i32 %j.06.i, 1
+ %39 = icmp ult i32 %38, 10000
+ br i1 %39, label %.lr.ph.i3, label %checkSum.exit
+
+checkSum.exit: ; preds = %.lr.ph.i3
+ %40 = add i32 %37, 2
+ %41 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str2, i32 0, i32 0), i32 %40) nounwind
+ ret i32 0
+}
+
+declare i32 @sscanf(i8* nocapture, i8* nocapture, ...) nounwind
+
+declare i32 @printf(i8* nocapture, ...) nounwind
diff --git a/tests/cases/muli33_ta2.txt b/tests/cases/muli33_ta2.txt
new file mode 100644
index 00000000..21e0231f
--- /dev/null
+++ b/tests/cases/muli33_ta2.txt
@@ -0,0 +1 @@
+res = 3164
diff --git a/tests/cases/philoop_ta2.ll b/tests/cases/philoop_ta2.ll
new file mode 100644
index 00000000..5036c7ba
--- /dev/null
+++ b/tests/cases/philoop_ta2.ll
@@ -0,0 +1,305 @@
+; ModuleID = '/tmp/tmpVIBz29/a.out.bc'
+target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
+target triple = "le32-unknown-nacl"
+
+@.str = private unnamed_addr constant [13 x i8] c"99\0A70\0A26\0A97\0A\00", align 1
+@.str1 = private unnamed_addr constant [12 x i8] c"%u %u %u %u\00", align 1
+@.str2 = private unnamed_addr constant [10 x i8] c"res = %u\0A\00", align 1
+
+define i32 @main() nounwind {
+ %jp0 = alloca i32, align 4
+ %i1 = alloca i32, align 4
+ %jq3 = alloca i32, align 4
+ %i = alloca i32, align 4
+ %cq = alloca [100 x i32], align 4
+ %ye = alloca [100 x i32], align 4
+ %g = alloca [100 x i32], align 4
+ %z = alloca [100 x i32], align 4
+ %za = alloca [100 x [100 x i32]], align 4
+ %a0 = alloca [100 x i32], align 4
+ store i32 99, i32* %jp0, align 4
+ store i32 70, i32* %i1, align 4
+ store i32 26, i32* %jq3, align 4
+ store i32 97, i32* %i, align 4
+ br label %.lr.ph.i
+
+.lr.ph.i: ; preds = %.lr.ph.i, %0
+ %j.07.i = phi i32 [ %7, %.lr.ph.i ], [ 0, %0 ]
+ %1 = and i32 %j.07.i, 1
+ %2 = icmp eq i32 %1, 0
+ %3 = sub i32 0, %j.07.i
+ %.p.i = select i1 %2, i32 %j.07.i, i32 %3
+ %4 = add i32 %.p.i, 2
+ %5 = urem i32 %4, 101
+ %6 = getelementptr inbounds [100 x i32]* %cq, i32 0, i32 %j.07.i
+ store i32 %5, i32* %6, align 4
+ %7 = add i32 %j.07.i, 1
+ %8 = icmp ult i32 %7, 100
+ br i1 %8, label %.lr.ph.i, label %.lr.ph.i44.preheader
+
+.lr.ph.i44.preheader: ; preds = %.lr.ph.i
+ %9 = getelementptr inbounds [100 x i32]* %a0, i32 0, i32 0
+ br label %.lr.ph.i44
+
+.lr.ph.i44: ; preds = %.lr.ph.i44, %.lr.ph.i44.preheader
+ %j.07.i42 = phi i32 [ %16, %.lr.ph.i44 ], [ 0, %.lr.ph.i44.preheader ]
+ %10 = and i32 %j.07.i42, 1
+ %11 = icmp eq i32 %10, 0
+ %12 = sub i32 0, %j.07.i42
+ %.p.i43 = select i1 %11, i32 %j.07.i42, i32 %12
+ %13 = add i32 %.p.i43, 90
+ %14 = urem i32 %13, 101
+ %15 = getelementptr inbounds [100 x i32]* %ye, i32 0, i32 %j.07.i42
+ store i32 %14, i32* %15, align 4
+ %16 = add i32 %j.07.i42, 1
+ %17 = icmp ult i32 %16, 100
+ br i1 %17, label %.lr.ph.i44, label %.lr.ph.i40
+
+.lr.ph.i40: ; preds = %.lr.ph.i40, %.lr.ph.i44
+ %j.07.i38 = phi i32 [ %24, %.lr.ph.i40 ], [ 0, %.lr.ph.i44 ]
+ %18 = and i32 %j.07.i38, 1
+ %19 = icmp eq i32 %18, 0
+ %20 = sub i32 0, %j.07.i38
+ %.p.i39 = select i1 %19, i32 %j.07.i38, i32 %20
+ %21 = add i32 %.p.i39, 73
+ %22 = urem i32 %21, 101
+ %23 = getelementptr inbounds [100 x i32]* %g, i32 0, i32 %j.07.i38
+ store i32 %22, i32* %23, align 4
+ %24 = add i32 %j.07.i38, 1
+ %25 = icmp ult i32 %24, 100
+ br i1 %25, label %.lr.ph.i40, label %.lr.ph.i36
+
+.lr.ph.i36: ; preds = %.lr.ph.i36, %.lr.ph.i40
+ %j.07.i34 = phi i32 [ %32, %.lr.ph.i36 ], [ 0, %.lr.ph.i40 ]
+ %26 = and i32 %j.07.i34, 1
+ %27 = icmp eq i32 %26, 0
+ %28 = sub i32 0, %j.07.i34
+ %.p.i35 = select i1 %27, i32 %j.07.i34, i32 %28
+ %29 = add i32 %.p.i35, 54
+ %30 = urem i32 %29, 101
+ %31 = getelementptr inbounds [100 x i32]* %z, i32 0, i32 %j.07.i34
+ store i32 %30, i32* %31, align 4
+ %32 = add i32 %j.07.i34, 1
+ %33 = icmp ult i32 %32, 100
+ br i1 %33, label %.lr.ph.i36, label %.lr.ph.i32
+
+.lr.ph.i32: ; preds = %.lr.ph.i32, %.lr.ph.i36
+ %j.07.i30 = phi i32 [ %40, %.lr.ph.i32 ], [ 0, %.lr.ph.i36 ]
+ %34 = and i32 %j.07.i30, 1
+ %35 = icmp eq i32 %34, 0
+ %36 = sub i32 0, %j.07.i30
+ %.p.i31 = select i1 %35, i32 %j.07.i30, i32 %36
+ %37 = add i32 %.p.i31, 66
+ %38 = urem i32 %37, 101
+ %39 = getelementptr inbounds [100 x [100 x i32]]* %za, i32 0, i32 0, i32 %j.07.i30
+ store i32 %38, i32* %39, align 4
+ %40 = add i32 %j.07.i30, 1
+ %41 = icmp ult i32 %40, 10000
+ br i1 %41, label %.lr.ph.i32, label %.lr.ph.i28
+
+.lr.ph.i28: ; preds = %.lr.ph.i28, %.lr.ph.i32
+ %j.07.i26 = phi i32 [ %48, %.lr.ph.i28 ], [ 0, %.lr.ph.i32 ]
+ %42 = and i32 %j.07.i26, 1
+ %43 = icmp eq i32 %42, 0
+ %44 = sub i32 0, %j.07.i26
+ %.p.i27 = select i1 %43, i32 %j.07.i26, i32 %44
+ %45 = add i32 %.p.i27, 71
+ %46 = urem i32 %45, 101
+ %47 = getelementptr inbounds [100 x i32]* %a0, i32 0, i32 %j.07.i26
+ store i32 %46, i32* %47, align 4
+ %48 = add i32 %j.07.i26, 1
+ %49 = icmp ult i32 %48, 100
+ br i1 %49, label %.lr.ph.i28, label %init.exit29
+
+init.exit29: ; preds = %.lr.ph.i28
+ %50 = call i32 (i8*, i8*, ...)* @sscanf(i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8]* @.str1, i32 0, i32 0), i32* %jp0, i32* %i1, i32* %jq3, i32* %i) nounwind
+ %51 = getelementptr inbounds [100 x i32]* %cq, i32 0, i32 46
+ %52 = load i32* %51, align 4
+ %53 = getelementptr inbounds [100 x i32]* %cq, i32 0, i32 20
+ %54 = load i32* %53, align 4
+ %55 = icmp ult i32 %52, %54
+ br i1 %55, label %.preheader61, label %56
+
+; <label>:56 ; preds = %init.exit29
+ %57 = load i32* %9, align 4
+ %58 = getelementptr inbounds [100 x i32]* %ye, i32 0, i32 24
+ %59 = load i32* %58, align 4
+ %60 = sub i32 %59, %57
+ store i32 %60, i32* %58, align 4
+ br label %.preheader61
+
+.preheader61: ; preds = %56, %init.exit29
+ store i32 2, i32* %jp0, align 4
+ %.phi.trans.insert = getelementptr inbounds [100 x i32]* %cq, i32 0, i32 1
+ %.pre = load i32* %.phi.trans.insert, align 4
+ br label %61
+
+.preheader58: ; preds = %61
+ store i32 80, i32* %jp0, align 4
+ store i32 94, i32* %i1, align 4
+ br label %76
+
+; <label>:61 ; preds = %61, %.preheader61
+ %62 = phi i32 [ %.pre, %.preheader61 ], [ %66, %61 ]
+ %63 = phi i32 [ 2, %.preheader61 ], [ %71, %61 ]
+ %64 = getelementptr inbounds [100 x i32]* %cq, i32 0, i32 %63
+ %65 = load i32* %64, align 4
+ %66 = add i32 %65, -4
+ store i32 %66, i32* %64, align 4
+ %67 = add i32 %63, -1
+ %68 = getelementptr inbounds [100 x i32]* %ye, i32 0, i32 %67
+ %69 = load i32* %68, align 4
+ %70 = mul i32 %62, %69
+ %71 = add i32 %63, 1
+ %72 = getelementptr inbounds [100 x i32]* %g, i32 0, i32 %71
+ %73 = load i32* %72, align 4
+ %74 = sub i32 %73, %70
+ store i32 %74, i32* %72, align 4
+ %75 = icmp ult i32 %71, 80
+ br i1 %75, label %61, label %.preheader58
+
+.preheader55: ; preds = %76
+ store i32 2, i32* %i1, align 4
+ store i32 44, i32* %jq3, align 4
+ br label %.preheader
+
+; <label>:76 ; preds = %76, %.preheader58
+ %77 = phi i32 [ 94, %.preheader58 ], [ %80, %76 ]
+ %78 = getelementptr inbounds [100 x i32]* %ye, i32 0, i32 %77
+ %79 = load i32* %78, align 4
+ %80 = add i32 %77, -1
+ %81 = getelementptr inbounds [100 x i32]* %z, i32 0, i32 %80
+ store i32 %79, i32* %81, align 4
+ %82 = icmp ugt i32 %80, 2
+ br i1 %82, label %76, label %.preheader55
+
+.preheader: ; preds = %95, %.preheader55
+ %83 = phi i32 [ 44, %.preheader55 ], [ %84, %95 ]
+ %84 = add i32 %83, -1
+ %85 = getelementptr inbounds [100 x [100 x i32]]* %za, i32 0, i32 %84, i32 %83
+ %.promoted = load i32* %85, align 4
+ %.pre75 = load i32* %9, align 4
+ %.phi.trans.insert76 = getelementptr inbounds [100 x i32]* %a0, i32 0, i32 1
+ %.pre77 = load i32* %.phi.trans.insert76, align 4
+ br label %86
+
+; <label>:86 ; preds = %86, %.preheader
+ %87 = phi i32 [ %.pre77, %.preheader ], [ %88, %86 ]
+ %88 = phi i32 [ %.pre75, %.preheader ], [ %87, %86 ]
+ %89 = phi i32 [ 1, %.preheader ], [ %92, %86 ]
+ %90 = phi i32 [ %.promoted, %.preheader ], [ %91, %86 ]
+ %91 = mul i32 %90, %87
+ %92 = add i32 %89, 1
+ %93 = getelementptr inbounds [100 x i32]* %a0, i32 0, i32 %92
+ store i32 %88, i32* %93, align 4
+ %94 = icmp ult i32 %92, 46
+ br i1 %94, label %86, label %95
+
+; <label>:95 ; preds = %86
+ store i32 %91, i32* %85, align 4
+ %96 = icmp ugt i32 %84, 1
+ br i1 %96, label %.preheader, label %97
+
+; <label>:97 ; preds = %95
+ store i32 1, i32* %jq3, align 4
+ store i32 46, i32* %i, align 4
+ br label %.lr.ph.i24
+
+.lr.ph.i24: ; preds = %.lr.ph.i24, %97
+ %sum.07.i22 = phi i32 [ %104, %.lr.ph.i24 ], [ 0, %97 ]
+ %j.06.i23 = phi i32 [ %105, %.lr.ph.i24 ], [ 0, %97 ]
+ %98 = and i32 %j.06.i23, 1
+ %99 = icmp eq i32 %98, 0
+ %100 = getelementptr inbounds [100 x i32]* %cq, i32 0, i32 %j.06.i23
+ %101 = load i32* %100, align 4
+ %102 = sub i32 0, %101
+ %103 = select i1 %99, i32 %101, i32 %102
+ %104 = add i32 %103, %sum.07.i22
+ %105 = add i32 %j.06.i23, 1
+ %106 = icmp ult i32 %105, 100
+ br i1 %106, label %.lr.ph.i24, label %.lr.ph.i20
+
+.lr.ph.i20: ; preds = %.lr.ph.i20, %.lr.ph.i24
+ %sum.07.i18 = phi i32 [ %113, %.lr.ph.i20 ], [ 0, %.lr.ph.i24 ]
+ %j.06.i19 = phi i32 [ %114, %.lr.ph.i20 ], [ 0, %.lr.ph.i24 ]
+ %107 = and i32 %j.06.i19, 1
+ %108 = icmp eq i32 %107, 0
+ %109 = getelementptr inbounds [100 x i32]* %ye, i32 0, i32 %j.06.i19
+ %110 = load i32* %109, align 4
+ %111 = sub i32 0, %110
+ %112 = select i1 %108, i32 %110, i32 %111
+ %113 = add i32 %112, %sum.07.i18
+ %114 = add i32 %j.06.i19, 1
+ %115 = icmp ult i32 %114, 100
+ br i1 %115, label %.lr.ph.i20, label %.lr.ph.i16
+
+.lr.ph.i16: ; preds = %.lr.ph.i16, %.lr.ph.i20
+ %sum.07.i14 = phi i32 [ %122, %.lr.ph.i16 ], [ 0, %.lr.ph.i20 ]
+ %j.06.i15 = phi i32 [ %123, %.lr.ph.i16 ], [ 0, %.lr.ph.i20 ]
+ %116 = and i32 %j.06.i15, 1
+ %117 = icmp eq i32 %116, 0
+ %118 = getelementptr inbounds [100 x i32]* %g, i32 0, i32 %j.06.i15
+ %119 = load i32* %118, align 4
+ %120 = sub i32 0, %119
+ %121 = select i1 %117, i32 %119, i32 %120
+ %122 = add i32 %121, %sum.07.i14
+ %123 = add i32 %j.06.i15, 1
+ %124 = icmp ult i32 %123, 100
+ br i1 %124, label %.lr.ph.i16, label %.lr.ph.i12
+
+.lr.ph.i12: ; preds = %.lr.ph.i12, %.lr.ph.i16
+ %sum.07.i10 = phi i32 [ %131, %.lr.ph.i12 ], [ 0, %.lr.ph.i16 ]
+ %j.06.i11 = phi i32 [ %132, %.lr.ph.i12 ], [ 0, %.lr.ph.i16 ]
+ %125 = and i32 %j.06.i11, 1
+ %126 = icmp eq i32 %125, 0
+ %127 = getelementptr inbounds [100 x i32]* %z, i32 0, i32 %j.06.i11
+ %128 = load i32* %127, align 4
+ %129 = sub i32 0, %128
+ %130 = select i1 %126, i32 %128, i32 %129
+ %131 = add i32 %130, %sum.07.i10
+ %132 = add i32 %j.06.i11, 1
+ %133 = icmp ult i32 %132, 100
+ br i1 %133, label %.lr.ph.i12, label %.lr.ph.i8
+
+.lr.ph.i8: ; preds = %.lr.ph.i8, %.lr.ph.i12
+ %sum.07.i6 = phi i32 [ %140, %.lr.ph.i8 ], [ 0, %.lr.ph.i12 ]
+ %j.06.i7 = phi i32 [ %141, %.lr.ph.i8 ], [ 0, %.lr.ph.i12 ]
+ %134 = and i32 %j.06.i7, 1
+ %135 = icmp eq i32 %134, 0
+ %136 = getelementptr inbounds [100 x [100 x i32]]* %za, i32 0, i32 0, i32 %j.06.i7
+ %137 = load i32* %136, align 4
+ %138 = sub i32 0, %137
+ %139 = select i1 %135, i32 %137, i32 %138
+ %140 = add i32 %139, %sum.07.i6
+ %141 = add i32 %j.06.i7, 1
+ %142 = icmp ult i32 %141, 10000
+ br i1 %142, label %.lr.ph.i8, label %.lr.ph.i5
+
+.lr.ph.i5: ; preds = %.lr.ph.i5, %.lr.ph.i8
+ %sum.07.i = phi i32 [ %149, %.lr.ph.i5 ], [ 0, %.lr.ph.i8 ]
+ %j.06.i = phi i32 [ %150, %.lr.ph.i5 ], [ 0, %.lr.ph.i8 ]
+ %143 = and i32 %j.06.i, 1
+ %144 = icmp eq i32 %143, 0
+ %145 = getelementptr inbounds [100 x i32]* %a0, i32 0, i32 %j.06.i
+ %146 = load i32* %145, align 4
+ %147 = sub i32 0, %146
+ %148 = select i1 %144, i32 %146, i32 %147
+ %149 = add i32 %148, %sum.07.i
+ %150 = add i32 %j.06.i, 1
+ %151 = icmp ult i32 %150, 100
+ br i1 %151, label %.lr.ph.i5, label %checkSum.exit
+
+checkSum.exit: ; preds = %.lr.ph.i5
+ %152 = add i32 %104, 82
+ %153 = add i32 %152, %113
+ %154 = sub i32 %153, %122
+ %155 = add i32 %154, %131
+ %156 = sub i32 %155, %140
+ %157 = add i32 %156, %149
+ %158 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str2, i32 0, i32 0), i32 %157) nounwind
+ ret i32 0
+}
+
+declare i32 @sscanf(i8* nocapture, i8* nocapture, ...) nounwind
+
+declare i32 @printf(i8* nocapture, ...) nounwind
diff --git a/tests/cases/philoop_ta2.txt b/tests/cases/philoop_ta2.txt
new file mode 100644
index 00000000..d5117fe8
--- /dev/null
+++ b/tests/cases/philoop_ta2.txt
@@ -0,0 +1 @@
+res = 1962923669
diff --git a/tests/files.cpp b/tests/files.cpp
index 04baa151..176cdb62 100644
--- a/tests/files.cpp
+++ b/tests/files.cpp
@@ -56,6 +56,9 @@ int main()
fwrite(data, 1, 5, outf);
fclose(outf);
+ FILE *devNull = fopen("/dev/null", "rb");
+ assert(devNull);
+
char data2[10];
FILE *inf = fopen("go.out", "rb");
int num = fread(data2, 1, 10, inf);
diff --git a/tests/full_es2_sdlproc.c b/tests/full_es2_sdlproc.c
new file mode 100644
index 00000000..d9ac072b
--- /dev/null
+++ b/tests/full_es2_sdlproc.c
@@ -0,0 +1,727 @@
+/*
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Ported to GLES2.
+ * Kristian Høgsberg <krh@bitplanet.net>
+ * May 3, 2010
+ *
+ * Improve GLES2 port:
+ * * Refactor gear drawing.
+ * * Use correct normals for surfaces.
+ * * Improve shader.
+ * * Use perspective projection transformation.
+ * * Add FPS count.
+ * * Add comments.
+ * Alexandros Frantzis <alexandros.frantzis@linaro.org>
+ * Jul 13, 2010
+ */
+
+#define GL_GLEXT_PROTOTYPES
+#define EGL_EGLEXT_PROTOTYPES
+
+#define _GNU_SOURCE
+
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <GL/gl.h>
+#include <GL/glut.h>
+
+#ifndef HAVE_BUILTIN_SINCOS
+#include "sincos.h"
+#endif
+
+#define STRIPS_PER_TOOTH 7
+#define VERTICES_PER_TOOTH 34
+#define GEAR_VERTEX_STRIDE 6
+
+/**
+ * Struct describing the vertices in triangle strip
+ */
+struct vertex_strip {
+ /** The first vertex in the strip */
+ GLint first;
+ /** The number of consecutive vertices in the strip after the first */
+ GLint count;
+};
+
+/* Each vertex consist of GEAR_VERTEX_STRIDE GLfloat attributes */
+typedef GLfloat GearVertex[GEAR_VERTEX_STRIDE];
+
+/**
+ * Struct representing a gear.
+ */
+struct gear {
+ /** The array of vertices comprising the gear */
+ GearVertex *vertices;
+ /** The number of vertices comprising the gear */
+ int nvertices;
+ /** The array of triangle strips comprising the gear */
+ struct vertex_strip *strips;
+ /** The number of triangle strips comprising the gear */
+ int nstrips;
+ /** The Vertex Buffer Object holding the vertices in the graphics card */
+ GLuint vbo;
+};
+
+/** The view rotation [x, y, z] */
+static GLfloat view_rot[3] = { 20.0, 30.0, 0.0 };
+/** The gears */
+static struct gear *gear1, *gear2, *gear3;
+/** The current gear rotation angle */
+static GLfloat angle = 0.0;
+/** The location of the shader uniforms */
+static GLuint ModelViewProjectionMatrix_location,
+ NormalMatrix_location,
+ LightSourcePosition_location,
+ MaterialColor_location;
+/** The projection matrix */
+static GLfloat ProjectionMatrix[16];
+/** The direction of the directional light for the scene */
+static const GLfloat LightSourcePosition[4] = { 5.0, 5.0, 10.0, 1.0};
+
+/**
+ * Fills a gear vertex.
+ *
+ * @param v the vertex to fill
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @param z the z coortinate
+ * @param n pointer to the normal table
+ *
+ * @return the operation error code
+ */
+static GearVertex *
+vert(GearVertex *v, GLfloat x, GLfloat y, GLfloat z, GLfloat n[3])
+{
+ v[0][0] = x;
+ v[0][1] = y;
+ v[0][2] = z;
+ v[0][3] = n[0];
+ v[0][4] = n[1];
+ v[0][5] = n[2];
+
+ return v + 1;
+}
+
+/**
+ * Create a gear wheel.
+ *
+ * @param inner_radius radius of hole at center
+ * @param outer_radius radius at center of teeth
+ * @param width width of gear
+ * @param teeth number of teeth
+ * @param tooth_depth depth of tooth
+ *
+ * @return pointer to the constructed struct gear
+ */
+static struct gear *
+create_gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
+ GLint teeth, GLfloat tooth_depth)
+{
+ GLfloat r0, r1, r2;
+ GLfloat da;
+ GearVertex *v;
+ struct gear *gear;
+ double s[5], c[5];
+ GLfloat normal[3];
+ int cur_strip = 0;
+ int i;
+
+ /* Allocate memory for the gear */
+ gear = malloc(sizeof *gear);
+ if (gear == NULL)
+ return NULL;
+
+ /* Calculate the radii used in the gear */
+ r0 = inner_radius;
+ r1 = outer_radius - tooth_depth / 2.0;
+ r2 = outer_radius + tooth_depth / 2.0;
+
+ da = 2.0 * M_PI / teeth / 4.0;
+
+ /* Allocate memory for the triangle strip information */
+ gear->nstrips = STRIPS_PER_TOOTH * teeth;
+ gear->strips = calloc(gear->nstrips, sizeof (*gear->strips));
+
+ /* Allocate memory for the vertices */
+ gear->vertices = calloc(VERTICES_PER_TOOTH * teeth, sizeof(*gear->vertices));
+ v = gear->vertices;
+
+ for (i = 0; i < teeth; i++) {
+ /* Calculate needed sin/cos for varius angles */
+ sincos(i * 2.0 * M_PI / teeth, &s[0], &c[0]);
+ sincos(i * 2.0 * M_PI / teeth + da, &s[1], &c[1]);
+ sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
+ sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
+ sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
+
+ /* A set of macros for making the creation of the gears easier */
+#define GEAR_POINT(r, da) { (r) * c[(da)], (r) * s[(da)] }
+#define SET_NORMAL(x, y, z) do { \
+ normal[0] = (x); normal[1] = (y); normal[2] = (z); \
+} while(0)
+
+#define GEAR_VERT(v, point, sign) vert((v), p[(point)].x, p[(point)].y, (sign) * width * 0.5, normal)
+
+#define START_STRIP do { \
+ gear->strips[cur_strip].first = v - gear->vertices; \
+} while(0);
+
+#define END_STRIP do { \
+ int _tmp = (v - gear->vertices); \
+ gear->strips[cur_strip].count = _tmp - gear->strips[cur_strip].first; \
+ cur_strip++; \
+} while (0)
+
+#define QUAD_WITH_NORMAL(p1, p2) do { \
+ SET_NORMAL((p[(p1)].y - p[(p2)].y), -(p[(p1)].x - p[(p2)].x), 0); \
+ v = GEAR_VERT(v, (p1), -1); \
+ v = GEAR_VERT(v, (p1), 1); \
+ v = GEAR_VERT(v, (p2), -1); \
+ v = GEAR_VERT(v, (p2), 1); \
+} while(0)
+
+ struct point {
+ GLfloat x;
+ GLfloat y;
+ };
+
+ /* Create the 7 points (only x,y coords) used to draw a tooth */
+ struct point p[7] = {
+ GEAR_POINT(r2, 1), // 0
+ GEAR_POINT(r2, 2), // 1
+ GEAR_POINT(r1, 0), // 2
+ GEAR_POINT(r1, 3), // 3
+ GEAR_POINT(r0, 0), // 4
+ GEAR_POINT(r1, 4), // 5
+ GEAR_POINT(r0, 4), // 6
+ };
+
+ /* Front face */
+ START_STRIP;
+ SET_NORMAL(0, 0, 1.0);
+ v = GEAR_VERT(v, 0, +1);
+ v = GEAR_VERT(v, 1, +1);
+ v = GEAR_VERT(v, 2, +1);
+ v = GEAR_VERT(v, 3, +1);
+ v = GEAR_VERT(v, 4, +1);
+ v = GEAR_VERT(v, 5, +1);
+ v = GEAR_VERT(v, 6, +1);
+ END_STRIP;
+
+ /* Inner face */
+ START_STRIP;
+ QUAD_WITH_NORMAL(4, 6);
+ END_STRIP;
+
+ /* Back face */
+ START_STRIP;
+ SET_NORMAL(0, 0, -1.0);
+ v = GEAR_VERT(v, 6, -1);
+ v = GEAR_VERT(v, 5, -1);
+ v = GEAR_VERT(v, 4, -1);
+ v = GEAR_VERT(v, 3, -1);
+ v = GEAR_VERT(v, 2, -1);
+ v = GEAR_VERT(v, 1, -1);
+ v = GEAR_VERT(v, 0, -1);
+ END_STRIP;
+
+ /* Outer face */
+ START_STRIP;
+ QUAD_WITH_NORMAL(0, 2);
+ END_STRIP;
+
+ START_STRIP;
+ QUAD_WITH_NORMAL(1, 0);
+ END_STRIP;
+
+ START_STRIP;
+ QUAD_WITH_NORMAL(3, 1);
+ END_STRIP;
+
+ START_STRIP;
+ QUAD_WITH_NORMAL(5, 3);
+ END_STRIP;
+ }
+
+ gear->nvertices = (v - gear->vertices);
+
+ /* Store the vertices in a vertex buffer object (VBO) */
+ glGenBuffers(1, &gear->vbo);
+ glBindBuffer(GL_ARRAY_BUFFER, gear->vbo);
+ glBufferData(GL_ARRAY_BUFFER, gear->nvertices * sizeof(GearVertex),
+ gear->vertices, GL_STATIC_DRAW);
+
+ return gear;
+}
+
+/**
+ * Multiplies two 4x4 matrices.
+ *
+ * The result is stored in matrix m.
+ *
+ * @param m the first matrix to multiply
+ *