#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, float *);
int strlen(char *);
float get_exposure(char *name) {
  FILE *fp;
  char exposure[] = "Exposure: ";
  unsigned char c;
  int fc;
  int i;
  int last;
  char line[500];
  float time;
  if ((fp = fopen(name, "rb")) == NULL) {
    printf("Couldn't open %s file.\n", name);
    return -999.0;
  }
  last = strlen(exposure);
  time = -999.0;
  i = 0;
  while ((fc = fgetc(fp)) != EOF) {
    c = (unsigned char)fc;
    if (c != exposure[i]) {
      i = 0;
    } else {
      i = i + 1;
    }
    if (i == last) {
      i = 0;
      do {
        fc = fgetc(fp);
        c = (unsigned char)fc;
        line[i] = c;
        i++;
      } while (c != ' ');
      line[i - 1] = '\0';
      sscanf(line, "%e", &time);
      break;
    }
  }
  fclose(fp);
  return time;
}


x86 assembly (clang, -O0):
<get_exposure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xe8e(%rip),%rax
mov    %rax,-0x23(%rbp)
mov    0xe8b(%rip),%ax
mov    %ax,-0x1b(%rbp)
mov    0xe83(%rip),%al
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ce <get_exposure+0x6e>
mov    -0x10(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1050 <printf@plt>
movss  0xe3c(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12cf <get_exposure+0x16f>
lea    -0x23(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x30(%rbp)
movss  0xe1e(%rip),%xmm0
movss  %xmm0,-0x234(%rbp)
ff
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x28(%rbp)
mov    0x2de4(%rip),%rcx
cmp    (%rcx),%eax
je     12b9 <get_exposure+0x159>
mov    -0x28(%rbp),%eax
mov    %al,-0x24(%rbp)
movzbl -0x24(%rbp),%eax
movslq -0x2c(%rbp),%rcx
movsbl -0x23(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     1233 <get_exposure+0xd3>
movl   $0x0,-0x2c(%rbp)
jmp    123c <get_exposure+0xdc>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jne    12b4 <get_exposure+0x154>
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %al,-0x24(%rbp)
mov    -0x24(%rbp),%cl
movslq -0x2c(%rbp),%rax
mov    %cl,-0x230(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movzbl -0x24(%rbp),%eax
cmp    $0x20,%eax
jne    124f <get_exposure+0xef>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x230(%rbp,%rax,1)
lea    -0x230(%rbp),%rdi
lea    0xd87(%rip),%rsi
lea    -0x234(%rbp),%rdx
call   1070 <sscanf@plt>
jmp    12b9 <get_exposure+0x159>
jmp    11f1 <get_exposure+0x91>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movss  -0x234(%rbp),%xmm0
ff
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_exposure>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x218,%rsp
mov    %rdi,%rbp
movabs $0x657275736f707845,%rax
75 72 65
mov    %rax,0x10(%rsp)
movl   $0x203a65,0x17(%rsp)
lea    0xe81(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1241 <get_exposure+0xe1>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
movl   $0xc479c000,0xc(%rsp)
c4
xor    %ebp,%ebp
mov    0x2e2b(%rip),%r14
jmp    11c7 <get_exposure+0x67>
nop
xor    %ebp,%ebp
cmp    %r15d,%ebp
je     11eb <get_exposure+0x8b>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    (%r14),%eax
je     1231 <get_exposure+0xd1>
movzbl %al,%eax
movslq %ebp,%rcx
movsbl 0x10(%rsp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11c0 <get_exposure+0x60>
add    $0x1,%ebp
cmp    %r15d,%ebp
jne    11c7 <get_exposure+0x67>
mov    $0xffffffffffffffff,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    %al,0x21(%rsp,%rbp,1)
add    $0x1,%rbp
cmp    $0x20,%al
jne    1200 <get_exposure+0xa0>
mov    %ebp,%eax
movb   $0x0,0x20(%rsp,%rax,1)
lea    0xe08(%rip),%rsi
lea    0x20(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1070 <sscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
movss  0xc(%rsp),%xmm0
jmp    1258 <get_exposure+0xf8>
lea    0xdca(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
movss  0xda8(%rip),%xmm0
add    $0x218,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.get_exposure.exposure = [11 x i8] c"Exposure: \00"
@.str = [3 x i8] c"rb\00"
@.str.1 = [24 x i8] c"Couldn't open %s file.\0A\00"
@EOF = global i32 0
@.str.2 = [3 x i8] c"%e\00"
define float @get_exposure(i8* %0) {
%2 = alloca float
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [11 x i8]
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [500 x i8]
%11 = alloca float
store i8* %0, i8** %3
%12 = bitcast [11 x i8]* %5 to i8*
%13 = load i8*, i8** %3
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store float -9.990000e+02, float* %2
br label %74
19: ; preds = %1
%20 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %9
store float -9.990000e+02, float* %11
store i32 0, i32* %8
br label %22
22: ; preds = %69, %19
%23 = load i32*, i32** %4
%24 = call i32 @fgetc(i32* %23)
store i32 %24, i32* %7
%25 = load i32, i32* @EOF
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %70
27: ; preds = %22
%28 = load i32, i32* %7
%29 = trunc i32 %28 to i8
store i8 %29, i8* %6
%30 = load i8, i8* %6
%31 = zext i8 %30 to i32
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %31, %36
br i1 %37, label %38, label %39
38: ; preds = %27
store i32 0, i32* %8
br label %42
39: ; preds = %27
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %42
42: ; preds = %39, %38
%43 = load i32, i32* %8
%44 = load i32, i32* %9
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %69
46: ; preds = %42
store i32 0, i32* %8
br label %47
47: ; preds = %58, %46
%48 = load i32*, i32** %4
%49 = call i32 @fgetc(i32* %48)
store i32 %49, i32* %7
%50 = load i32, i32* %7
%51 = trunc i32 %50 to i8
store i8 %51, i8* %6
%52 = load i8, i8* %6
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [500 x i8], [500 x i8]* %10, i64 0, i64 %54
store i8 %52, i8* %55
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %58
58: ; preds = %47
%59 = load i8, i8* %6
%60 = zext i8 %59 to i32
%61 = icmp ne i32 %60, 32
br i1 %61, label %47, label %62
62: ; preds = %58
%63 = load i32, i32* %8
%64 = sub nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [500 x i8], [500 x i8]* %10, i64 0, i64 %65
store i8 0, i8* %66
%67 = getelementptr inbounds [500 x i8], [500 x i8]* %10, i64 0, i64 0
%68 = call i32 @sscanf(i8* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %11)
br label %70
69: ; preds = %42
br label %22
70: ; preds = %62, %22
%71 = load i32*, i32** %4
%72 = call i32 @fclose(i32* %71)
%73 = load float, float* %11
store float %73, float* %2
br label %74
74: ; preds = %70, %16
%75 = load float, float* %2
ret float %75
}

LLVM IR (-O2):
@__const.get_exposure.exposure = [11 x i8] c"Exposure: \00"
@.str = [3 x i8] c"rb\00"
@.str.1 = [24 x i8] c"Couldn't open %s file.\0A\00"
@EOF = global i32 0
@.str.2 = [3 x i8] c"%e\00"
define float @get_exposure(i8* %0) {
%2 = alloca [11 x i8]
%3 = alloca [500 x i8]
%4 = alloca float
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%7 = bitcast float* %4 to i8*
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %44
12: ; preds = %1
%13 = call i32 @strlen(i8* %5)
store float -9.990000e+02, float* %4
br label %14
14: ; preds = %19, %12
%15 = phi i32 [ 0, %12 ], [ %27, %19 ]
%16 = call i32 @fgetc(i32* %8)
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %41, label %19
19: ; preds = %14
%20 = and i32 %16, 255
%21 = sext i32 %15 to i64
%22 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %20, %24
%26 = add nsw i32 %15, 1
%27 = select i1 %25, i32 %26, i32 0
%28 = icmp eq i32 %27, %13
br i1 %28, label %29, label %14
29: ; preds = %19, %29
%30 = phi i64 [ %34, %29 ], [ 0, %19 ]
%31 = call i32 @fgetc(i32* %8)
%32 = trunc i32 %31 to i8
%33 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 %30
store i8 %32, i8* %33
%34 = add nuw i64 %30, 1
%35 = and i32 %31, 255
%36 = icmp eq i32 %35, 32
br i1 %36, label %37, label %29
37: ; preds = %29
%38 = and i64 %30, 4294967295
%39 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 %38
store i8 0, i8* %39
%40 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %4)
br label %41
41: ; preds = %14, %37
%42 = call i32 @fclose(i32* %8)
%43 = load float, float* %4
br label %44
44: ; preds = %41, %10
%45 = phi float [ -9.990000e+02, %10 ], [ %43, %41 ]
ret float %45
}