#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdout;
void load_settings() {
  FILE *f = fopen("/tmp/file", "r");
  if (!f) {
    perror("fopen:");
  }
  char word[200];
  fscanf(f, "%s", word);
  printf("%s\n", word);
  fscanf(f, "%s", word);
  printf("%s\n", word);
  fflush(stdout);
  fclose(f);
}


x86 assembly (clang, -O0):
<load_settings>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
lea    0xe8e(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1199 <load_settings+0x39>
lea    0xe78(%rip),%rdi
call   1080 <perror@plt>
mov    -0x8(%rbp),%rdi
lea    -0xd0(%rbp),%rdx
lea    0xe68(%rip),%rsi
call   1050 <fscanf@plt>
lea    -0xd0(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0xd0(%rbp),%rdx
lea    0xe3e(%rip),%rsi
call   1050 <fscanf@plt>
lea    -0xd0(%rbp),%rsi
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_settings>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc8,%rsp
lea    0xe8b(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11f1 <load_settings+0x91>
lea    0xe83(%rip),%r14
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <fscanf@plt>
lea    0xe6e(%rip),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe14(%rip),%rdi
call   1080 <perror@plt>
jmp    1189 <load_settings+0x29>

LLVM IR (-O0):
@.str = [10 x i8] c"/tmp/file\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"fopen:\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@stdout = global i32 0
define void @load_settings() {
%1 = alloca i32*
%2 = alloca [200 x i8]
%3 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = icmp ne i32* %4, null
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = load i32*, i32** %1
%10 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%11 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %12)
%14 = load i32*, i32** %1
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%16 = call i32 @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
%21 = load i32*, i32** %1
%22 = call i32 @fclose(i32* %21)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"/tmp/file\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"fopen:\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@stdout = global i32 0
define void @load_settings() {
%1 = alloca [200 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 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 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %6
6: ; preds = %4, %0
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%8 = call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%10 = call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%12 = load i32, i32* @stdout
%13 = call i32 @fflush(i32 %12)
%14 = call i32 @fclose(i32* %2)
ret void
}