#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__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int main() {
  FILE *a = fopen("123", "a+");
  if (!a) {
    printf("cant open 123\n");
    return 0;
  }
  char b[10];
  while (fgets(b, 11, a)) {
    printf("%s\n", b);
  }
  char c = 'a';
  int d = 'a';
  if (!putc(d, a)) {
    printf("cnat put in");
    return 0;
  }
  printf("over\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118b <main+0x4b>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1212 <main+0xd2>
jmp    1190 <main+0x50>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xb,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11c3 <main+0x83>
lea    -0x1a(%rbp),%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1190 <main+0x50>
movb   $0x61,-0x1b(%rbp)
movl   $0x61,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <putc@plt>
cmp    $0x0,%eax
jne    11fd <main+0xbd>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1212 <main+0xd2>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c7 <main+0x77>
mov    %rax,%r14
lea    0xe(%rsp),%rdi
mov    $0xb,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11ad <main+0x5d>
lea    0xe(%rsp),%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1190 <main+0x40>
mov    $0x61,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
test   %eax,%eax
je     11d5 <main+0x85>
lea    0xe58(%rip),%rdi
jmp    11ce <main+0x7e>
lea    0xe41(%rip),%rdi
call   1030 <puts@plt>
jmp    11e3 <main+0x93>
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"123\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [15 x i8] c"cant open 123\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [12 x i8] c"cnat put in\00"
@.str.5 = [6 x i8] c"over\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [10 x i8]
%4 = alloca i8
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp ne i32* %7, null
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %29
11: ; preds = %0
br label %12
12: ; preds = %17, %11
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%14 = load i32*, i32** %2
%15 = call i64 @fgets(i8* %13, i32 11, i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %18)
br label %12
20: ; preds = %12
store i8 97, i8* %4
store i32 97, i32* %5
%21 = load i32, i32* %5
%22 = load i32*, i32** %2
%23 = call i32 @putc(i32 %21, i32* %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %29
27: ; preds = %20
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %29
29: ; preds = %27, %25, %9
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [4 x i8] c"123\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.4 = [12 x i8] c"cnat put in\00"
@str = [14 x i8] c"cant open 123\00"
@str.6 = [5 x i8] c"over\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %22
6: ; preds = %0
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%8 = call i64 @fgets(i8* %7, i32 11, i32* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %6, %10
%11 = call i32 @puts(i8* %7)
%12 = call i64 @fgets(i8* %7, i32 11, i32* %2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %10
14: ; preds = %10, %6
%15 = call i32 @putc(i32 97, i32* %2)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %21
19: ; preds = %14
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.6, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
br label %22
22: ; preds = %21, %4
ret i32 0
}