#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 */
scalar_t__ EOF;
scalar_t__ close(int);
int /*<<< orphan*/ fail(char *);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pr(char *);
int /*<<< orphan*/ unlink(char *);
void test_sio1(void) {
  FILE *f;
  char buf[80];
  int i, j;
  int fd;
  pr("fopen");
  if ((f = fopen("stdio.tmp", "w+")) == NULL) {
    fail("fopen-1");
  } else {
    pr("feof");
    fgetc(f);
    if (!feof(f))
      fail("feof-1");
    fclose(f);
  }
  if ((f = fopen("stdio.tmp", "w")) == NULL) {
    fail("fopen-2");
  } else {
    pr("fputs");
    if (fputs("1111111111\n", f) == EOF)
      fail("fputs-1");
    if (fputs("2222222222\n", f) == EOF)
      fail("fputs-2");
    if (fputs("3333333333\n", f) == EOF)
      fail("fputs-3");
    if (fputs("4444444444\n", f) == EOF)
      fail("fputs-4");
    if (fputs("5555555555\n", f) == EOF)
      fail("fputs-5");
    fd = fileno(f);
    pr("fclose");
    if (fclose(f))
      fail("fclose-1");
    if (close(fd) == 0)
      fail("fclose-2");
    if ((f = fopen("stdio.tmp", "r")) == NULL) {
      fail("fopen-3");
    } else {
      pr("fgets");
      fgets(buf, 80, f);
      i = '1';
      while (!feof(f)) {
        for (j = 0; j < 10; j++) {
          if (buf[j] != i) {
            fail("fgets-1");
            break;
          }
        }
        i++;
        fgets(buf, 80, f);
      }
      fd = fileno(f);
      if (fclose(f))
        fail("fclose-1");
      if (close(fd) == 0)
        fail("fclose-2");
    }
  }
  unlink("stdio.tmp");
}


x86 assembly (clang, -O0):
<test_sio1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    0xe41(%rip),%rdi
call   1070 <pr@plt>
lea    0xe3b(%rip),%rdi
lea    0xe3e(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    11f6 <test_sio1+0x46>
lea    0xe27(%rip),%rdi
call   1040 <fail@plt>
jmp    1232 <test_sio1+0x82>
lea    0xe1e(%rip),%rdi
call   1070 <pr@plt>
mov    -0x8(%rbp),%rdi
call   1080 <fgetc@plt>
mov    -0x8(%rbp),%rdi
call   10b0 <feof@plt>
cmp    $0x0,%eax
jne    1229 <test_sio1+0x79>
lea    0xdfc(%rip),%rdi
call   1040 <fail@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xdcd(%rip),%rdi
lea    0xde7(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    1264 <test_sio1+0xb4>
lea    0xdcf(%rip),%rdi
call   1040 <fail@plt>
jmp    14d0 <test_sio1+0x320>
lea    0xdc6(%rip),%rdi
call   1070 <pr@plt>
mov    -0x8(%rbp),%rsi
lea    0xdbc(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2d61(%rip),%rcx
cmp    (%rcx),%rax
jne    129c <test_sio1+0xec>
lea    0xdac(%rip),%rdi
call   1040 <fail@plt>
mov    -0x8(%rbp),%rsi
lea    0xda4(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2d35(%rip),%rcx
cmp    (%rcx),%rax
jne    12c8 <test_sio1+0x118>
lea    0xd94(%rip),%rdi
call   1040 <fail@plt>
mov    -0x8(%rbp),%rsi
lea    0xd8c(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2d09(%rip),%rcx
cmp    (%rcx),%rax
jne    12f4 <test_sio1+0x144>
lea    0xd7c(%rip),%rdi
call   1040 <fail@plt>
mov    -0x8(%rbp),%rsi
lea    0xd74(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2cdd(%rip),%rcx
cmp    (%rcx),%rax
jne    1320 <test_sio1+0x170>
lea    0xd64(%rip),%rdi
call   1040 <fail@plt>
mov    -0x8(%rbp),%rsi
lea    0xd5c(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2cb1(%rip),%rcx
cmp    (%rcx),%rax
jne    134c <test_sio1+0x19c>
lea    0xd4c(%rip),%rdi
call   1040 <fail@plt>
mov    -0x8(%rbp),%rdi
call   10c0 <fileno@plt>
mov    %eax,-0x6c(%rbp)
lea    0xd3c(%rip),%rdi
call   1070 <pr@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fclose@plt>
cmp    $0x0,%rax
je     1383 <test_sio1+0x1d3>
lea    0xd24(%rip),%rdi
call   1040 <fail@plt>
mov    -0x6c(%rbp),%edi
call   1090 <close@plt>
cmp    $0x0,%rax
jne    13a1 <test_sio1+0x1f1>
lea    0xd0f(%rip),%rdi
call   1040 <fail@plt>
lea    0xc5e(%rip),%rdi
lea    0xd05(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    13d3 <test_sio1+0x223>
lea    0xced(%rip),%rdi
call   1040 <fail@plt>
jmp    14cb <test_sio1+0x31b>
lea    0xce4(%rip),%rdi
call   1070 <pr@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x50,%esi
call   10a0 <fgets@plt>
movl   $0x31,-0x64(%rbp)
mov    -0x8(%rbp),%rdi
call   10b0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1416 <test_sio1+0x266>
jmp    147d <test_sio1+0x2cd>
movl   $0x0,-0x68(%rbp)
cmpl   $0xa,-0x68(%rbp)
jge    145d <test_sio1+0x2ad>
movslq -0x68(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    -0x64(%rbp),%eax
je     144a <test_sio1+0x29a>
lea    0xc84(%rip),%rdi
call   1040 <fail@plt>
jmp    145d <test_sio1+0x2ad>
jmp    144f <test_sio1+0x29f>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    141d <test_sio1+0x26d>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x50,%esi
call   10a0 <fgets@plt>
jmp    13f8 <test_sio1+0x248>
mov    -0x8(%rbp),%rdi
call   10c0 <fileno@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fclose@plt>
cmp    $0x0,%rax
je     14a8 <test_sio1+0x2f8>
lea    0xbff(%rip),%rdi
call   1040 <fail@plt>
mov    -0x6c(%rbp),%edi
call   1090 <close@plt>
cmp    $0x0,%rax
jne    14c6 <test_sio1+0x316>
lea    0xbea(%rip),%rdi
call   1040 <fail@plt>
jmp    14cb <test_sio1+0x31b>
jmp    14d0 <test_sio1+0x320>
lea    0xb2f(%rip),%rdi
call   1030 <unlink@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_sio1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xe3f(%rip),%rdi
call   1070 <pr@plt>
lea    0xe39(%rip),%rdi
lea    0xe3c(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1217 <test_sio1+0x67>
mov    %rax,%rbx
lea    0xe33(%rip),%rdi
call   1070 <pr@plt>
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
jne    120d <test_sio1+0x5d>
lea    0xe18(%rip),%rdi
call   1040 <fail@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    1223 <test_sio1+0x73>
lea    0xdf5(%rip),%rdi
call   1040 <fail@plt>
lea    0xddc(%rip),%rdi
lea    0xdf6(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13bc <test_sio1+0x20c>
mov    %rax,%rbx
lea    0xde8(%rip),%rdi
call   1070 <pr@plt>
lea    0xde2(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    0x2d84(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    1276 <test_sio1+0xc6>
lea    0xdd2(%rip),%rdi
call   1040 <fail@plt>
lea    0xdce(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
cmp    0x0(%rbp),%rax
jne    1297 <test_sio1+0xe7>
lea    0xdc5(%rip),%rdi
call   1040 <fail@plt>
lea    0xdc1(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
cmp    0x0(%rbp),%rax
jne    12b8 <test_sio1+0x108>
lea    0xdb8(%rip),%rdi
call   1040 <fail@plt>
lea    0xdb4(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
cmp    0x0(%rbp),%rax
jne    12d9 <test_sio1+0x129>
lea    0xdab(%rip),%rdi
call   1040 <fail@plt>
lea    0xda7(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
cmp    0x0(%rbp),%rax
jne    12fa <test_sio1+0x14a>
lea    0xd9e(%rip),%rdi
call   1040 <fail@plt>
mov    %rbx,%rdi
call   10c0 <fileno@plt>
mov    %eax,%ebp
lea    0xd90(%rip),%rdi
call   1070 <pr@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   %rax,%rax
je     1329 <test_sio1+0x179>
lea    0xd7e(%rip),%rdi
call   1040 <fail@plt>
mov    %ebp,%edi
call   1090 <close@plt>
test   %rax,%rax
jne    1341 <test_sio1+0x191>
lea    0xd6f(%rip),%rdi
call   1040 <fail@plt>
lea    0xcbe(%rip),%rdi
lea    0xd65(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13c5 <test_sio1+0x215>
mov    %rax,%rbx
lea    0xd5b(%rip),%rdi
call   1070 <pr@plt>
mov    %rsp,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   10a0 <fgets@plt>
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
je     13e8 <test_sio1+0x238>
mov    %rbx,%rdi
call   10c0 <fileno@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   %rax,%rax
je     13a7 <test_sio1+0x1f7>
lea    0xd00(%rip),%rdi
call   1040 <fail@plt>
mov    %ebp,%edi
call   1090 <close@plt>
test   %rax,%rax
jne    13d1 <test_sio1+0x221>
lea    0xcf1(%rip),%rdi
jmp    13cc <test_sio1+0x21c>
lea    0xc66(%rip),%rdi
jmp    13cc <test_sio1+0x21c>
lea    0xcea(%rip),%rdi
call   1040 <fail@plt>
lea    0xc2e(%rip),%rdi
call   1030 <unlink@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x31,%ebp
mov    %rsp,%r14
lea    0xccd(%rip),%r15
jmp    142b <test_sio1+0x27b>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1040 <fail@plt>
add    $0x1,%ebp
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   10a0 <fgets@plt>
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
jne    1384 <test_sio1+0x1d4>
movq   (%rsp),%xmm0
punpcklbw %xmm0,%xmm0
punpcklwd %xmm0,%xmm1
psrad  $0x18,%xmm1
punpckhwd %xmm0,%xmm0
psrad  $0x18,%xmm0
movd   %ebp,%xmm2
pshufd $0x0,%xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
psllw  $0xf,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%eax
cmp    $0xff,%al
jne    1400 <test_sio1+0x250>
movsbl 0x8(%rsp),%eax
cmp    %eax,%ebp
jne    1400 <test_sio1+0x250>
movsbl 0x9(%rsp),%eax
cmp    %eax,%ebp
je     1408 <test_sio1+0x258>
jmp    1400 <test_sio1+0x250>

LLVM IR (-O0):
@.str = [6 x i8] c"fopen\00"
@.str.1 = [10 x i8] c"stdio.tmp\00"
@.str.2 = [3 x i8] c"w+\00"
@.str.3 = [8 x i8] c"fopen-1\00"
@.str.4 = [5 x i8] c"feof\00"
@.str.5 = [7 x i8] c"feof-1\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [8 x i8] c"fopen-2\00"
@.str.8 = [6 x i8] c"fputs\00"
@.str.9 = [12 x i8] c"1111111111\0A\00"
@EOF = global i64 0
@.str.10 = [8 x i8] c"fputs-1\00"
@.str.11 = [12 x i8] c"2222222222\0A\00"
@.str.12 = [8 x i8] c"fputs-2\00"
@.str.13 = [12 x i8] c"3333333333\0A\00"
@.str.14 = [8 x i8] c"fputs-3\00"
@.str.15 = [12 x i8] c"4444444444\0A\00"
@.str.16 = [8 x i8] c"fputs-4\00"
@.str.17 = [12 x i8] c"5555555555\0A\00"
@.str.18 = [8 x i8] c"fputs-5\00"
@.str.19 = [7 x i8] c"fclose\00"
@.str.20 = [9 x i8] c"fclose-1\00"
@.str.21 = [9 x i8] c"fclose-2\00"
@.str.22 = [2 x i8] c"r\00"
@.str.23 = [8 x i8] c"fopen-3\00"
@.str.24 = [6 x i8] c"fgets\00"
@.str.25 = [8 x i8] c"fgets-1\00"
define void @test_sio1() {
%1 = alloca i32*
%2 = alloca [80 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 @pr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %7, i32** %1
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %23
11: ; preds = %0
%12 = call i32 @pr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%13 = load i32*, i32** %1
%14 = call i32 @fgetc(i32* %13)
%15 = load i32*, i32** %1
%16 = call i32 @feof(i32* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %11
%19 = call i32 @fail(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %20
20: ; preds = %18, %11
%21 = load i32*, i32** %1
%22 = call i64 @fclose(i32* %21)
br label %23
23: ; preds = %20, %9
%24 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %24, i32** %1
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %134
28: ; preds = %23
%29 = call i32 @pr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%30 = load i32*, i32** %1
%31 = call i64 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32* %30)
%32 = load i64, i64* @EOF
%33 = icmp eq i64 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
br label %36
36: ; preds = %34, %28
%37 = load i32*, i32** %1
%38 = call i64 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32* %37)
%39 = load i64, i64* @EOF
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
br label %43
43: ; preds = %41, %36
%44 = load i32*, i32** %1
%45 = call i64 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32* %44)
%46 = load i64, i64* @EOF
%47 = icmp eq i64 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0))
br label %50
50: ; preds = %48, %43
%51 = load i32*, i32** %1
%52 = call i64 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i32* %51)
%53 = load i64, i64* @EOF
%54 = icmp eq i64 %52, %53
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0))
br label %57
57: ; preds = %55, %50
%58 = load i32*, i32** %1
%59 = call i64 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i32* %58)
%60 = load i64, i64* @EOF
%61 = icmp eq i64 %59, %60
br i1 %61, label %62, label %64
62: ; preds = %57
%63 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0))
br label %64
64: ; preds = %62, %57
%65 = load i32*, i32** %1
%66 = call i32 @fileno(i32* %65)
store i32 %66, i32* %5
%67 = call i32 @pr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
%68 = load i32*, i32** %1
%69 = call i64 @fclose(i32* %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %64
%72 = call i32 @fail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0))
br label %73
73: ; preds = %71, %64
%74 = load i32, i32* %5
%75 = call i64 @close(i32 %74)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i32 @fail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.21, i64 0, i64 0))
br label %79
79: ; preds = %77, %73
%80 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.22, i64 0, i64 0))
store i32* %80, i32** %1
%81 = icmp eq i32* %80, null
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0))
br label %133
84: ; preds = %79
%85 = call i32 @pr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.24, i64 0, i64 0))
%86 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%87 = load i32*, i32** %1
%88 = call i32 @fgets(i8* %86, i32 80, i32* %87)
store i32 49, i32* %3
br label %89
89: ; preds = %112, %84
%90 = load i32*, i32** %1
%91 = call i32 @feof(i32* %90)
%92 = icmp ne i32 %91, 0
%93 = xor i1 %92, true
br i1 %93, label %94, label %118
94: ; preds = %89
store i32 0, i32* %4
br label %95
95: ; preds = %109, %94
%96 = load i32, i32* %4
%97 = icmp slt i32 %96, 10
br i1 %97, label %98, label %112
98: ; preds = %95
%99 = load i32, i32* %4
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %100
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = load i32, i32* %3
%105 = icmp ne i32 %103, %104
br i1 %105, label %106, label %108
106: ; preds = %98
%107 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.25, i64 0, i64 0))
br label %112
108: ; preds = %98
br label %109
109: ; preds = %108
%110 = load i32, i32* %4
%111 = add nsw i32 %110, 1
store i32 %111, i32* %4
br label %95
112: ; preds = %106, %95
%113 = load i32, i32* %3
%114 = add nsw i32 %113, 1
store i32 %114, i32* %3
%115 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%116 = load i32*, i32** %1
%117 = call i32 @fgets(i8* %115, i32 80, i32* %116)
br label %89
118: ; preds = %89
%119 = load i32*, i32** %1
%120 = call i32 @fileno(i32* %119)
store i32 %120, i32* %5
%121 = load i32*, i32** %1
%122 = call i64 @fclose(i32* %121)
%123 = icmp ne i64 %122, 0
br i1 %123, label %124, label %126
124: ; preds = %118
%125 = call i32 @fail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0))
br label %126
126: ; preds = %124, %118
%127 = load i32, i32* %5
%128 = call i64 @close(i32 %127)
%129 = icmp eq i64 %128, 0
br i1 %129, label %130, label %132
130: ; preds = %126
%131 = call i32 @fail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.21, i64 0, i64 0))
br label %132
132: ; preds = %130, %126
br label %133
133: ; preds = %132, %82
br label %134
134: ; preds = %133, %26
%135 = call i32 @unlink(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"fopen\00"
@.str.1 = [10 x i8] c"stdio.tmp\00"
@.str.2 = [3 x i8] c"w+\00"
@.str.3 = [8 x i8] c"fopen-1\00"
@.str.4 = [5 x i8] c"feof\00"
@.str.5 = [7 x i8] c"feof-1\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [8 x i8] c"fopen-2\00"
@.str.8 = [6 x i8] c"fputs\00"
@.str.9 = [12 x i8] c"1111111111\0A\00"
@EOF = global i64 0
@.str.10 = [8 x i8] c"fputs-1\00"
@.str.11 = [12 x i8] c"2222222222\0A\00"
@.str.12 = [8 x i8] c"fputs-2\00"
@.str.13 = [12 x i8] c"3333333333\0A\00"
@.str.14 = [8 x i8] c"fputs-3\00"
@.str.15 = [12 x i8] c"4444444444\0A\00"
@.str.16 = [8 x i8] c"fputs-4\00"
@.str.17 = [12 x i8] c"5555555555\0A\00"
@.str.18 = [8 x i8] c"fputs-5\00"
@.str.19 = [7 x i8] c"fclose\00"
@.str.20 = [9 x i8] c"fclose-1\00"
@.str.21 = [9 x i8] c"fclose-2\00"
@.str.22 = [2 x i8] c"r\00"
@.str.23 = [8 x i8] c"fopen-3\00"
@.str.24 = [6 x i8] c"fgets\00"
@.str.25 = [8 x i8] c"fgets-1\00"
define void @test_sio1() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @pr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %17
8: ; preds = %0
%9 = tail call i32 @pr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @fgetc(i32* %4)
%11 = tail call i32 @feof(i32* %4)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @fail(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %15
15: ; preds = %13, %8
%16 = tail call i64 @fclose(i32* %4)
br label %17
17: ; preds = %15, %6
%18 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %115
22: ; preds = %17
%23 = tail call i32 @pr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%24 = tail call i64 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32* %18)
%25 = load i64, i64* @EOF
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = tail call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
%30 = tail call i64 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32* %18)
%31 = load i64, i64* @EOF
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = tail call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
br label %35
35: ; preds = %33, %29
%36 = tail call i64 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32* %18)
%37 = load i64, i64* @EOF
%38 = icmp eq i64 %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = tail call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0))
br label %41
41: ; preds = %39, %35
%42 = tail call i64 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i32* %18)
%43 = load i64, i64* @EOF
%44 = icmp eq i64 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = tail call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0))
br label %47
47: ; preds = %45, %41
%48 = tail call i64 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i32* %18)
%49 = load i64, i64* @EOF
%50 = icmp eq i64 %48, %49
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = tail call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0))
br label %53
53: ; preds = %51, %47
%54 = tail call i32 @fileno(i32* %18)
%55 = tail call i32 @pr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
%56 = tail call i64 @fclose(i32* %18)
%57 = icmp eq i64 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %53
%59 = tail call i32 @fail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0))
br label %60
60: ; preds = %58, %53
%61 = tail call i64 @close(i32 %54)
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = tail call i32 @fail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.21, i64 0, i64 0))
br label %65
65: ; preds = %63, %60
%66 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.22, i64 0, i64 0))
%67 = icmp eq i32* %66, null
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = tail call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0))
br label %115
70: ; preds = %65
%71 = tail call i32 @pr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.24, i64 0, i64 0))
%72 = call i32 @fgets(i8* %2, i32 80, i32* %66)
%73 = call i32 @feof(i32* %66)
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %104
75: ; preds = %70
%76 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 8
%77 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 9
%78 = bitcast [80 x i8]* %1 to <8 x i8>*
br label %79
79: ; preds = %75, %99
%80 = phi i32 [ %100, %99 ], [ 49, %75 ]
%81 = load <8 x i8>, <8 x i8>* %78
%82 = sext <8 x i8> %81 to <8 x i32>
%83 = insertelement <8 x i32> poison, i32 %80, i64 0
%84 = shufflevector <8 x i32> %83, <8 x i32> poison, <8 x i32> zeroinitializer
%85 = icmp eq <8 x i32> %84, %82
%86 = freeze <8 x i1> %85
%87 = bitcast <8 x i1> %86 to i8
%88 = icmp eq i8 %87, -1
%89 = load i8, i8* %76
%90 = sext i8 %89 to i32
%91 = icmp eq i32 %80, %90
%92 = select i1 %88, i1 %91, i1 false
%93 = load i8, i8* %77
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %80, %94
%96 = select i1 %92, i1 %95, i1 false
br i1 %96, label %99, label %97
97: ; preds = %79
%98 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.25, i64 0, i64 0))
br label %99
99: ; preds = %79, %97
%100 = add nuw nsw i32 %80, 1
%101 = call i32 @fgets(i8* %2, i32 80, i32* %66)
%102 = call i32 @feof(i32* %66)
%103 = icmp eq i32 %102, 0
br i1 %103, label %79, label %104
104: ; preds = %99, %70
%105 = call i32 @fileno(i32* %66)
%106 = call i64 @fclose(i32* %66)
%107 = icmp eq i64 %106, 0
br i1 %107, label %110, label %108
108: ; preds = %104
%109 = call i32 @fail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0))
br label %110
110: ; preds = %108, %104
%111 = call i64 @close(i32 %105)
%112 = icmp eq i64 %111, 0
br i1 %112, label %113, label %115
113: ; preds = %110
%114 = call i32 @fail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.21, i64 0, i64 0))
br label %115
115: ; preds = %68, %113, %110, %20
%116 = call i32 @unlink(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
ret void
}