#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 /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int main() {
  FILE *fp1;
  fp1 = fopen("foo.txt", "w+");
  fprintf(fp1, "hello world");
  int r = fputc('a', fp1);
  if (r == 'a') {
    r = fputc('b', fp1);
    if (r == 'b') {
      printf("Hola");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rsi
mov    $0x61,%edi
call   1040 <fputc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x61,-0x14(%rbp)
jne    11bd <main+0x7d>
mov    -0x10(%rbp),%rsi
mov    $0x62,%edi
call   1040 <fputc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x62,-0x14(%rbp)
jne    11b8 <main+0x78>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
jmp    11bd <main+0x7d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xead(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
mov    $0x61,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
cmp    $0x61,%eax
jne    11a0 <main+0x60>
mov    $0x62,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
cmp    $0x62,%eax
jne    11a0 <main+0x60>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"foo.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [12 x i8] c"hello world\00"
@.str.3 = [5 x i8] c"Hola\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32*, i32** %2
%8 = call i32 @fputc(i8 signext 97, i32* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 97
br i1 %10, label %11, label %19
11: ; preds = %0
%12 = load i32*, i32** %2
%13 = call i32 @fputc(i8 signext 98, i32* %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 98
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
br label %19
19: ; preds = %18, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"foo.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [12 x i8] c"hello world\00"
@.str.3 = [5 x i8] c"Hola\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 11, i64 1, i32* %1)
%3 = tail call i32 @fputc(i8 signext 97, i32* %1)
%4 = icmp eq i32 %3, 97
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = tail call i32 @fputc(i8 signext 98, i32* %1)
%7 = icmp eq i32 %6, 98
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %10
10: ; preds = %5, %8, %0
ret i32 0
}