#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ processCmd(char *);
readStartup() {
  FILE *fp;
  char line[1024];
  if (!(fp = fopen(".sre_init", "r")))
    return (0);
  while (fgets(line, 1000, fp) != NULL)
    processCmd(line);
  fclose(fp);
}


x86 assembly (clang, -O0):
<readStartup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    0xeae(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1178 <readStartup+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <readStartup+0x76>
jmp    117d <readStartup+0x3d>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11ad <readStartup+0x6d>
lea    -0x410(%rbp),%rdi
call   1030 <processCmd@plt>
jmp    117d <readStartup+0x3d>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readStartup>:
push   %r14
push   %rbx
sub    $0x408,%rsp
lea    0xeaf(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a5 <readStartup+0x65>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x3e8,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     119d <readStartup+0x5d>
mov    %rsp,%rbx
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <processCmd@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1180 <readStartup+0x40>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c".sre_init\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @readStartup() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [1024 x i8]
%4 = 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* %4, i32** %2
%5 = icmp ne i32* %4, null
br i1 %5, label %7, label %6
6: ; preds = %0
store i32 0, i32* %1
br label %19
7: ; preds = %0
br label %8
8: ; preds = %13, %7
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = load i32*, i32** %2
%11 = call i32* @fgets(i8* %9, i32 1000, i32* %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%15 = call i32 @processCmd(i8* %14)
br label %8
16: ; preds = %8
%17 = load i32*, i32** %2
%18 = call i32 @fclose(i32* %17)
br label %19
19: ; preds = %16, %6
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [10 x i8] c".sre_init\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @readStartup() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = 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))
%4 = icmp eq i32* %3, null
br i1 %4, label %14, label %5
5: ; preds = %0
%6 = call i32* @fgets(i8* %2, i32 1000, i32* %3)
%7 = icmp eq i32* %6, null
br i1 %7, label %12, label %8
8: ; preds = %5, %8
%9 = call i32 @processCmd(i8* %2)
%10 = call i32* @fgets(i8* %2, i32 1000, i32* %3)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %8
12: ; preds = %8, %5
%13 = call i32 @fclose(i32* %3)
br label %14
14: ; preds = %0, %12
ret i32 0
}