#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stderr;
char *tmpnam(int /*<<< orphan*/ *);
int ungetc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char *argv[]) {
  char *name;
  FILE *fp = NULL;
  int retval = 0;
  int c;
  name = tmpnam(NULL);
  fp = fopen(name, "w");
  if (!(fp != NULL)) {
    fputs("test failed: "
          "fp != NULL"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  }
  fputs("bla", fp);
  fclose(fp);
  fp = NULL;
  fp = fopen(name, "r");
  if (!(fp != NULL)) {
    fputs("test failed: "
          "fp != NULL"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(ungetc('z', fp) == 'z')) {
    fputs("test failed: "
          "ungetc ('z', fp) == 'z'"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(getc(fp) == 'z')) {
    fputs("test failed: "
          "getc (fp) == 'z'"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(getc(fp) == 'b')) {
    fputs("test failed: "
          "getc (fp) == 'b'"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(getc(fp) == 'l')) {
    fputs("test failed: "
          "getc (fp) == 'l'"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(ungetc('m', fp) == 'm')) {
    fputs("test failed: "
          "ungetc ('m', fp) == 'm'"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(getc(fp) == 'm')) {
    fputs("test failed: "
          "getc (fp) == 'm'"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!((c = getc(fp)) == 'a')) {
    fputs("test failed: "
          "(c = getc (fp)) == 'a'"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(getc(fp) == EOF)) {
    fputs("test failed: "
          "getc (fp) == EOF"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(ungetc(c, fp) == c)) {
    fputs("test failed: "
          "ungetc (c, fp) == c"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(feof(fp) == 0)) {
    fputs("test failed: "
          "feof (fp) == 0"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(getc(fp) == c)) {
    fputs("test failed: "
          "getc (fp) == c"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
  if (!(getc(fp) == EOF)) {
    fputs("test failed: "
          "getc (fp) == EOF"
          "\n",
          stderr);
    retval = 1;
    goto the_end;
  };
the_end:
  if (fp != NULL)
    fclose(fp);
  unlink(name);
  return retval;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <tmpnam@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f3 <main+0x73>
mov    0x2e00(%rip),%rax
mov    (%rax),%rsi
lea    0xe20(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rsi
lea    0xe1d(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe00(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1255 <main+0xd5>
mov    0x2d9e(%rip),%rax
mov    (%rax),%rsi
lea    0xdbe(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rsi
mov    $0x7a,%edi
call   1070 <ungetc@plt>
cmp    $0x7a,%eax
je     128e <main+0x10e>
mov    0x2d65(%rip),%rax
mov    (%rax),%rsi
lea    0xda4(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
cmp    $0x7a,%eax
je     12c2 <main+0x142>
mov    0x2d31(%rip),%rax
mov    (%rax),%rsi
lea    0xd96(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
cmp    $0x62,%eax
je     12f6 <main+0x176>
mov    0x2cfd(%rip),%rax
mov    (%rax),%rsi
lea    0xd81(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
cmp    $0x6c,%eax
je     132a <main+0x1aa>
mov    0x2cc9(%rip),%rax
mov    (%rax),%rsi
lea    0xd6c(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rsi
mov    $0x6d,%edi
call   1070 <ungetc@plt>
cmp    $0x6d,%eax
je     1363 <main+0x1e3>
mov    0x2c90(%rip),%rax
mov    (%rax),%rsi
lea    0xd52(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
cmp    $0x6d,%eax
je     1397 <main+0x217>
mov    0x2c5c(%rip),%rax
mov    (%rax),%rsi
lea    0xd44(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x61,%eax
je     13ce <main+0x24e>
mov    0x2c25(%rip),%rax
mov    (%rax),%rsi
lea    0xd2c(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
mov    0x2c0a(%rip),%rcx
cmp    (%rcx),%eax
je     1408 <main+0x288>
mov    0x2beb(%rip),%rax
mov    (%rax),%rsi
lea    0xd17(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <ungetc@plt>
cmp    -0x28(%rbp),%eax
je     143f <main+0x2bf>
mov    0x2bb4(%rip),%rax
mov    (%rax),%rsi
lea    0xcff(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     1474 <main+0x2f4>
mov    0x2b7f(%rip),%rax
mov    (%rax),%rsi
lea    0xcec(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
cmp    -0x28(%rbp),%eax
je     14a8 <main+0x328>
mov    0x2b4b(%rip),%rax
mov    (%rax),%rsi
lea    0xcd5(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
mov    0x2b30(%rip),%rcx
cmp    (%rcx),%eax
je     14e2 <main+0x362>
mov    0x2b11(%rip),%rax
mov    (%rax),%rsi
lea    0xc3d(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x24(%rbp)
jmp    14e7 <main+0x367>
jmp    14e7 <main+0x367>
cmpq   $0x0,-0x20(%rbp)
je     14fb <main+0x37b>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1090 <tmpnam@plt>
mov    %rax,%rbx
lea    0xe68(%rip),%rsi
mov    %rax,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     12c0 <main+0x140>
mov    %rax,%rbp
lea    0xe68(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xe4b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     12c0 <main+0x140>
mov    %rax,%r14
mov    $0x7a,%edi
mov    %rax,%rsi
call   1060 <ungetc@plt>
cmp    $0x7a,%eax
jne    12e7 <main+0x167>
mov    %r14,%rdi
call   10a0 <getc@plt>
cmp    $0x7a,%eax
jne    12ff <main+0x17f>
mov    %r14,%rdi
call   10a0 <getc@plt>
cmp    $0x62,%eax
jne    1312 <main+0x192>
mov    %r14,%rdi
call   10a0 <getc@plt>
cmp    $0x6c,%eax
jne    1325 <main+0x1a5>
mov    $0x6d,%edi
mov    %r14,%rsi
call   1060 <ungetc@plt>
cmp    $0x6d,%eax
jne    1367 <main+0x1e7>
mov    %r14,%rdi
call   10a0 <getc@plt>
cmp    $0x6d,%eax
jne    137f <main+0x1ff>
mov    %r14,%rdi
call   10a0 <getc@plt>
cmp    $0x61,%eax
jne    1392 <main+0x212>
mov    %r14,%rdi
call   10a0 <getc@plt>
mov    0x2d70(%rip),%r15
cmp    (%r15),%eax
jne    13e5 <main+0x265>
mov    $0x61,%edi
mov    %r14,%rsi
call   1060 <ungetc@plt>
cmp    $0x61,%eax
jne    13aa <main+0x22a>
mov    %r14,%rdi
call   1050 <feof@plt>
test   %rax,%rax
je     13c5 <main+0x245>
mov    0x2d29(%rip),%rax
mov    (%rax),%rcx
lea    0xe96(%rip),%rdi
mov    $0x1c,%esi
jmp    133b <main+0x1bb>
mov    0x2d11(%rip),%rax
mov    (%rax),%rcx
lea    0xd31(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    $0x1,%ebp
jmp    1352 <main+0x1d2>
mov    0x2cea(%rip),%rax
mov    (%rax),%rcx
lea    0xd29(%rip),%rdi
mov    $0x25,%esi
jmp    133b <main+0x1bb>
mov    0x2cd2(%rip),%rax
mov    (%rax),%rcx
lea    0xd37(%rip),%rdi
jmp    1336 <main+0x1b6>
mov    0x2cbf(%rip),%rax
mov    (%rax),%rcx
lea    0xd43(%rip),%rdi
jmp    1336 <main+0x1b6>
mov    0x2cac(%rip),%rax
mov    (%rax),%rcx
lea    0xd4f(%rip),%rdi
mov    $0x1e,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    $0x1,%ebp
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c6a(%rip),%rax
mov    (%rax),%rcx
lea    0xd2c(%rip),%rdi
mov    $0x25,%esi
jmp    133b <main+0x1bb>
mov    0x2c52(%rip),%rax
mov    (%rax),%rcx
lea    0xd3a(%rip),%rdi
jmp    1336 <main+0x1b6>
mov    0x2c3f(%rip),%rax
mov    (%rax),%rcx
lea    0xd46(%rip),%rdi
mov    $0x24,%esi
jmp    133b <main+0x1bb>
mov    0x2c27(%rip),%rax
mov    (%rax),%rcx
lea    0xd72(%rip),%rdi
mov    $0x21,%esi
jmp    133b <main+0x1bb>
mov    %r14,%rdi
call   10a0 <getc@plt>
cmp    $0x61,%eax
jne    13fb <main+0x27b>
mov    %r14,%rdi
call   10a0 <getc@plt>
xor    %ebp,%ebp
cmp    (%r15),%eax
je     134a <main+0x1ca>
mov    0x2bec(%rip),%rax
mov    (%rax),%rcx
lea    0xd18(%rip),%rdi
jmp    1336 <main+0x1b6>
mov    0x2bd6(%rip),%rax
mov    (%rax),%rcx
lea    0xd60(%rip),%rdi
mov    $0x1c,%esi
jmp    133b <main+0x1bb>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [25 x i8] c"test failed: fp != NULL\0A\00"
@stderr = global i32* null
@.str.2 = [4 x i8] c"bla\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [38 x i8] c"test failed: ungetc ('z', fp) == 'z'\0A\00"
@.str.5 = [31 x i8] c"test failed: getc (fp) == 'z'\0A\00"
@.str.6 = [31 x i8] c"test failed: getc (fp) == 'b'\0A\00"
@.str.7 = [31 x i8] c"test failed: getc (fp) == 'l'\0A\00"
@.str.8 = [38 x i8] c"test failed: ungetc ('m', fp) == 'm'\0A\00"
@.str.9 = [31 x i8] c"test failed: getc (fp) == 'm'\0A\00"
@.str.10 = [37 x i8] c"test failed: (c = getc (fp)) == 'a'\0A\00"
@EOF = global i32 0
@.str.11 = [31 x i8] c"test failed: getc (fp) == EOF\0A\00"
@.str.12 = [34 x i8] c"test failed: ungetc (c, fp) == c\0A\00"
@.str.13 = [29 x i8] c"test failed: feof (fp) == 0\0A\00"
@.str.14 = [29 x i8] c"test failed: getc (fp) == c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %7
store i32 0, i32* %8
%10 = call i8* @tmpnam(i32* null)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %7
%13 = load i32*, i32** %7
%14 = icmp ne i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i32*, i32** @stderr
%17 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32* %16)
store i32 1, i32* %8
br label %120
18: ; preds = %2
%19 = load i32*, i32** %7
%20 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %19)
%21 = load i32*, i32** %7
%22 = call i32 @fclose(i32* %21)
store i32* null, i32** %7
%23 = load i8*, i8** %6
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %24, i32** %7
%25 = load i32*, i32** %7
%26 = icmp ne i32* %25, null
br i1 %26, label %30, label %27
27: ; preds = %18
%28 = load i32*, i32** @stderr
%29 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32* %28)
store i32 1, i32* %8
br label %120
30: ; preds = %18
%31 = load i32*, i32** %7
%32 = call i32 @ungetc(i32 122, i32* %31)
%33 = icmp eq i32 %32, 122
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load i32*, i32** @stderr
%36 = call i32 @fputs(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32* %35)
store i32 1, i32* %8
br label %120
37: ; preds = %30
%38 = load i32*, i32** %7
%39 = call i32 @getc(i32* %38)
%40 = icmp eq i32 %39, 122
br i1 %40, label %44, label %41
41: ; preds = %37
%42 = load i32*, i32** @stderr
%43 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32* %42)
store i32 1, i32* %8
br label %120
44: ; preds = %37
%45 = load i32*, i32** %7
%46 = call i32 @getc(i32* %45)
%47 = icmp eq i32 %46, 98
br i1 %47, label %51, label %48
48: ; preds = %44
%49 = load i32*, i32** @stderr
%50 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32* %49)
store i32 1, i32* %8
br label %120
51: ; preds = %44
%52 = load i32*, i32** %7
%53 = call i32 @getc(i32* %52)
%54 = icmp eq i32 %53, 108
br i1 %54, label %58, label %55
55: ; preds = %51
%56 = load i32*, i32** @stderr
%57 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32* %56)
store i32 1, i32* %8
br label %120
58: ; preds = %51
%59 = load i32*, i32** %7
%60 = call i32 @ungetc(i32 109, i32* %59)
%61 = icmp eq i32 %60, 109
br i1 %61, label %65, label %62
62: ; preds = %58
%63 = load i32*, i32** @stderr
%64 = call i32 @fputs(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32* %63)
store i32 1, i32* %8
br label %120
65: ; preds = %58
%66 = load i32*, i32** %7
%67 = call i32 @getc(i32* %66)
%68 = icmp eq i32 %67, 109
br i1 %68, label %72, label %69
69: ; preds = %65
%70 = load i32*, i32** @stderr
%71 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32* %70)
store i32 1, i32* %8
br label %120
72: ; preds = %65
%73 = load i32*, i32** %7
%74 = call i32 @getc(i32* %73)
store i32 %74, i32* %9
%75 = icmp eq i32 %74, 97
br i1 %75, label %79, label %76
76: ; preds = %72
%77 = load i32*, i32** @stderr
%78 = call i32 @fputs(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i32* %77)
store i32 1, i32* %8
br label %120
79: ; preds = %72
%80 = load i32*, i32** %7
%81 = call i32 @getc(i32* %80)
%82 = load i32, i32* @EOF
%83 = icmp eq i32 %81, %82
br i1 %83, label %87, label %84
84: ; preds = %79
%85 = load i32*, i32** @stderr
%86 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i32* %85)
store i32 1, i32* %8
br label %120
87: ; preds = %79
%88 = load i32, i32* %9
%89 = load i32*, i32** %7
%90 = call i32 @ungetc(i32 %88, i32* %89)
%91 = load i32, i32* %9
%92 = icmp eq i32 %90, %91
br i1 %92, label %96, label %93
93: ; preds = %87
%94 = load i32*, i32** @stderr
%95 = call i32 @fputs(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0), i32* %94)
store i32 1, i32* %8
br label %120
96: ; preds = %87
%97 = load i32*, i32** %7
%98 = call i64 @feof(i32* %97)
%99 = icmp eq i64 %98, 0
br i1 %99, label %103, label %100
100: ; preds = %96
%101 = load i32*, i32** @stderr
%102 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i32* %101)
store i32 1, i32* %8
br label %120
103: ; preds = %96
%104 = load i32*, i32** %7
%105 = call i32 @getc(i32* %104)
%106 = load i32, i32* %9
%107 = icmp eq i32 %105, %106
br i1 %107, label %111, label %108
108: ; preds = %103
%109 = load i32*, i32** @stderr
%110 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i64 0, i64 0), i32* %109)
store i32 1, i32* %8
br label %120
111: ; preds = %103
%112 = load i32*, i32** %7
%113 = call i32 @getc(i32* %112)
%114 = load i32, i32* @EOF
%115 = icmp eq i32 %113, %114
br i1 %115, label %119, label %116
116: ; preds = %111
%117 = load i32*, i32** @stderr
%118 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i32* %117)
store i32 1, i32* %8
br label %120
119: ; preds = %111
br label %120
120: ; preds = %119, %116, %108, %100, %93, %84, %76, %69, %62, %55, %48, %41, %34, %27, %15
%121 = load i32*, i32** %7
%122 = icmp ne i32* %121, null
br i1 %122, label %123, label %126
123: ; preds = %120
%124 = load i32*, i32** %7
%125 = call i32 @fclose(i32* %124)
br label %126
126: ; preds = %123, %120
%127 = load i8*, i8** %6
%128 = call i32 @unlink(i8* %127)
%129 = load i32, i32* %8
ret i32 %129
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [25 x i8] c"test failed: fp != NULL\0A\00"
@stderr = global i32* null
@.str.2 = [4 x i8] c"bla\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [38 x i8] c"test failed: ungetc ('z', fp) == 'z'\0A\00"
@.str.5 = [31 x i8] c"test failed: getc (fp) == 'z'\0A\00"
@.str.6 = [31 x i8] c"test failed: getc (fp) == 'b'\0A\00"
@.str.7 = [31 x i8] c"test failed: getc (fp) == 'l'\0A\00"
@.str.8 = [38 x i8] c"test failed: ungetc ('m', fp) == 'm'\0A\00"
@.str.9 = [31 x i8] c"test failed: getc (fp) == 'm'\0A\00"
@.str.10 = [37 x i8] c"test failed: (c = getc (fp)) == 'a'\0A\00"
@EOF = global i32 0
@.str.11 = [31 x i8] c"test failed: getc (fp) == EOF\0A\00"
@.str.12 = [34 x i8] c"test failed: ungetc (c, fp) == c\0A\00"
@.str.13 = [29 x i8] c"test failed: feof (fp) == 0\0A\00"
@.str.14 = [29 x i8] c"test failed: getc (fp) == c\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @tmpnam(i32* null)
%4 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32*, i32** @stderr
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 24, i64 1, i32* %7)
br label %94
9: ; preds = %2
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 3, i64 1, i32* %4)
%11 = tail call i32 @fclose(i32* %4)
%12 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i32*, i32** @stderr
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 24, i64 1, i32* %15)
br label %94
17: ; preds = %9
%18 = tail call i32 @ungetc(i32 122, i32* %12)
%19 = icmp eq i32 %18, 122
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32*, i32** @stderr
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i64 37, i64 1, i32* %21)
br label %91
23: ; preds = %17
%24 = tail call i32 @getc(i32* %12)
%25 = icmp eq i32 %24, 122
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32*, i32** @stderr
%28 = tail call i64 @fwrite(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i64 30, i64 1, i32* %27)
br label %91
29: ; preds = %23
%30 = tail call i32 @getc(i32* %12)
%31 = icmp eq i32 %30, 98
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = load i32*, i32** @stderr
%34 = tail call i64 @fwrite(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i64 30, i64 1, i32* %33)
br label %91
35: ; preds = %29
%36 = tail call i32 @getc(i32* %12)
%37 = icmp eq i32 %36, 108
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = load i32*, i32** @stderr
%40 = tail call i64 @fwrite(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i64 30, i64 1, i32* %39)
br label %91
41: ; preds = %35
%42 = tail call i32 @ungetc(i32 109, i32* %12)
%43 = icmp eq i32 %42, 109
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i32*, i32** @stderr
%46 = tail call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i64 37, i64 1, i32* %45)
br label %91
47: ; preds = %41
%48 = tail call i32 @getc(i32* %12)
%49 = icmp eq i32 %48, 109
br i1 %49, label %53, label %50
50: ; preds = %47
%51 = load i32*, i32** @stderr
%52 = tail call i64 @fwrite(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i64 30, i64 1, i32* %51)
br label %91
53: ; preds = %47
%54 = tail call i32 @getc(i32* %12)
%55 = icmp eq i32 %54, 97
br i1 %55, label %59, label %56
56: ; preds = %53
%57 = load i32*, i32** @stderr
%58 = tail call i64 @fwrite(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i64 36, i64 1, i32* %57)
br label %91
59: ; preds = %53
%60 = tail call i32 @getc(i32* %12)
%61 = load i32, i32* @EOF
%62 = icmp eq i32 %60, %61
br i1 %62, label %66, label %63
63: ; preds = %59
%64 = load i32*, i32** @stderr
%65 = tail call i64 @fwrite(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i64 30, i64 1, i32* %64)
br label %91
66: ; preds = %59
%67 = tail call i32 @ungetc(i32 97, i32* %12)
%68 = icmp eq i32 %67, 97
br i1 %68, label %72, label %69
69: ; preds = %66
%70 = load i32*, i32** @stderr
%71 = tail call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0), i64 33, i64 1, i32* %70)
br label %91
72: ; preds = %66
%73 = tail call i64 @feof(i32* %12)
%74 = icmp eq i64 %73, 0
br i1 %74, label %78, label %75
75: ; preds = %72
%76 = load i32*, i32** @stderr
%77 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i64 28, i64 1, i32* %76)
br label %91
78: ; preds = %72
%79 = tail call i32 @getc(i32* %12)
%80 = icmp eq i32 %79, 97
br i1 %80, label %84, label %81
81: ; preds = %78
%82 = load i32*, i32** @stderr
%83 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i64 0, i64 0), i64 28, i64 1, i32* %82)
br label %91
84: ; preds = %78
%85 = tail call i32 @getc(i32* %12)
%86 = load i32, i32* @EOF
%87 = icmp eq i32 %85, %86
br i1 %87, label %91, label %88
88: ; preds = %84
%89 = load i32*, i32** @stderr
%90 = tail call i64 @fwrite(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i64 30, i64 1, i32* %89)
br label %91
91: ; preds = %84, %88, %81, %75, %69, %63, %56, %50, %44, %38, %32, %26, %20
%92 = phi i32 [ 1, %20 ], [ 1, %26 ], [ 1, %32 ], [ 1, %38 ], [ 1, %44 ], [ 1, %50 ], [ 1, %56 ], [ 1, %63 ], [ 1, %69 ], [ 1, %75 ], [ 1, %81 ], [ 1, %88 ], [ 0, %84 ]
%93 = tail call i32 @fclose(i32* %12)
br label %94
94: ; preds = %6, %14, %91
%95 = phi i32 [ %92, %91 ], [ 1, %14 ], [ 1, %6 ]
%96 = tail call i32 @unlink(i8* %3)
ret i32 %95
}