#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 uint8_t;
typedef int /*<<< orphan*/ int32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int seek_definition(int /*<<< orphan*/ *, char *);
int read_int(FILE *f, char *config_path, int32_t *result) {
  int success;
  uint8_t temp;
  success = seek_definition(f, config_path);
  if (success != 0)
    return success;
  temp = fgetc(f);
  if (temp != 1)
    return 1;
  temp = fgetc(f);
  if (temp != 2)
    return 2;
  while (fgetc(f) != 0)
    ;
  fread(result, 4, 1, f);
  return 0;
}


x86 assembly (clang, -O0):
<read_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <seek_definition@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1169 <read_int+0x39>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e7 <read_int+0xb7>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
je     118b <read_int+0x5b>
movl   $0x1,-0x4(%rbp)
jmp    11e7 <read_int+0xb7>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x2,-0x28(%rbp)
je     11ad <read_int+0x7d>
movl   $0x2,-0x4(%rbp)
jmp    11e7 <read_int+0xb7>
jmp    11b2 <read_int+0x82>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
cmp    $0x0,%eax
je     11c9 <read_int+0x99>
jmp    11b2 <read_int+0x82>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_int>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
call   1050 <seek_definition@plt>
test   %eax,%eax
jne    1193 <read_int+0x63>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x1,%ecx
jne    1193 <read_int+0x63>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    $0x2,%ecx
jne    1193 <read_int+0x63>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <fgetc@plt>
test   %eax,%eax
jne    1170 <read_int+0x40>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @read_int(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%10 = load i32*, i32** %5
%11 = load i8*, i8** %6
%12 = call i32 @seek_definition(i32* %10, i8* %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = load i32, i32* %8
store i32 %16, i32* %4
br label %39
17: ; preds = %3
%18 = load i32*, i32** %5
%19 = call i32 @fgetc(i32* %18)
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = icmp ne i32 %20, 1
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 1, i32* %4
br label %39
23: ; preds = %17
%24 = load i32*, i32** %5
%25 = call i32 @fgetc(i32* %24)
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = icmp ne i32 %26, 2
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 2, i32* %4
br label %39
29: ; preds = %23
br label %30
30: ; preds = %34, %29
%31 = load i32*, i32** %5
%32 = call i32 @fgetc(i32* %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
br label %30
35: ; preds = %30
%36 = load i32*, i32** %7
%37 = load i32*, i32** %5
%38 = call i32 @fread(i32* %36, i32 4, i32 1, i32* %37)
store i32 0, i32* %4
br label %39
39: ; preds = %35, %28, %22, %15
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
define i32 @read_int(i32* %0, i8* %1, i32* nocapture %2) {
%4 = tail call i32 @seek_definition(i32* %0, i8* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = tail call i32 @fgetc(i32* %0)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = tail call i32 @fgetc(i32* %0)
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %9, %12
%13 = tail call i32 @fgetc(i32* %0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %12
15: ; preds = %12
%16 = tail call i32 @fread(i32* %2, i32 4, i32 1, i32* %0)
br label %17
17: ; preds = %9, %6, %3, %15
%18 = phi i32 [ 0, %15 ], [ %4, %3 ], [ 1, %6 ], [ 2, %9 ]
ret i32 %18
}