#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 */
float atof(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int split(char *, char **, int);
int /*<<< orphan*/ strcmp(char *, char *);
int iget_t4_scale(char *t4file, float *scale) {
  FILE *fp;
  char string[256], *srgv[256];
  int m, err;
  *scale = 1.;
  err = 1;
  if (!(fp = fopen(t4file, "r")))
    return -1;
  printf("Reading: %s\n", t4file);
  while (fgets(string, 256, fp)) {
    if (!(m = split(string, srgv, 256)))
      continue;
    if (!strcmp(srgv[0], "scale:") && m > 1) {
      *scale = atof(srgv[1]);
      err = 0;
    }
  }
  fclose(fp);
  return err;
}


x86 assembly (clang, -O0):
<iget_t4_scale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x930,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movss  0xe71(%rip),%xmm0
movss  %xmm0,(%rax)
movl   $0x1,-0x928(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11c7 <iget_t4_scale+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    1280 <iget_t4_scale+0x110>
mov    -0x10(%rbp),%rsi
lea    0xe34(%rip),%rdi
call   1050 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     126e <iget_t4_scale+0xfe>
lea    -0x120(%rbp),%rdi
lea    -0x920(%rbp),%rsi
mov    $0x100,%edx
call   1060 <split@plt>
mov    %eax,-0x924(%rbp)
cmp    $0x0,%eax
jne    1222 <iget_t4_scale+0xb2>
jmp    11d7 <iget_t4_scale+0x67>
mov    -0x920(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1269 <iget_t4_scale+0xf9>
cmpl   $0x1,-0x924(%rbp)
jle    1269 <iget_t4_scale+0xf9>
mov    -0x918(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x928(%rbp)
jmp    11d7 <iget_t4_scale+0x67>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x928(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x930,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iget_t4_scale>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x908,%rsp
mov    %rsi,%r14
mov    %rdi,%rbp
movl   $0x3f800000,(%rsi)
lea    0xe6c(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     123b <iget_t4_scale+0xcb>
mov    %rax,%rbx
lea    0xe56(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    $0x1,%r15d
mov    %rsp,%rbp
lea    0x100(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1231 <iget_t4_scale+0xc1>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x100,%edx
call   1060 <split@plt>
test   %eax,%eax
je     11d0 <iget_t4_scale+0x60>
mov    %eax,%r13d
mov    0x100(%rsp),%rdi
lea    0xe04(%rip),%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
jne    11d0 <iget_t4_scale+0x60>
cmp    $0x2,%r13d
jl     11d0 <iget_t4_scale+0x60>
mov    0x108(%rsp),%rdi
call   1030 <atof@plt>
movss  %xmm0,(%r14)
xor    %r15d,%r15d
jmp    11d0 <iget_t4_scale+0x60>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1241 <iget_t4_scale+0xd1>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x908,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [13 x i8] c"Reading: %s\0A\00"
@.str.2 = [7 x i8] c"scale:\00"
define i32 @iget_t4_scale(i8* %0, float* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca float*
%6 = alloca i32*
%7 = alloca [256 x i8]
%8 = alloca [256 x i8*]
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store float* %1, float** %5
%11 = load float*, float** %5
store float 1.000000e+00, float* %11
store i32 1, i32* %10
%12 = load i8*, i8** %4
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
%14 = icmp ne i32* %13, null
br i1 %14, label %16, label %15
15: ; preds = %2
store i32 -1, i32* %3
br label %48
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %43, %29, %16
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%21 = load i32*, i32** %6
%22 = call i64 @fgets(i8* %20, i32 256, i32* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %44
24: ; preds = %19
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%26 = getelementptr inbounds [256 x i8*], [256 x i8*]* %8, i64 0, i64 0
%27 = call i32 @split(i8* %25, i8** %26, i32 256)
store i32 %27, i32* %9
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %24
br label %19
30: ; preds = %24
%31 = getelementptr inbounds [256 x i8*], [256 x i8*]* %8, i64 0, i64 0
%32 = load i8*, i8** %31
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %43, label %35
35: ; preds = %30
%36 = load i32, i32* %9
%37 = icmp sgt i32 %36, 1
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = getelementptr inbounds [256 x i8*], [256 x i8*]* %8, i64 0, i64 1
%40 = load i8*, i8** %39
%41 = call float @atof(i8* %40)
%42 = load float*, float** %5
store float %41, float* %42
store i32 0, i32* %10
br label %43
43: ; preds = %38, %35, %30
br label %19
44: ; preds = %19
%45 = load i32*, i32** %6
%46 = call i32 @fclose(i32* %45)
%47 = load i32, i32* %10
store i32 %47, i32* %3
br label %48
48: ; preds = %44, %15
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [13 x i8] c"Reading: %s\0A\00"
@.str.2 = [7 x i8] c"scale:\00"
define i32 @iget_t4_scale(i8* %0, float* nocapture writeonly %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8*]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast [256 x i8*]* %4 to i8*
store float 1.000000e+00, float* %1
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %33, label %9
9: ; preds = %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = getelementptr inbounds [256 x i8*], [256 x i8*]* %4, i64 0, i64 0
%12 = getelementptr inbounds [256 x i8*], [256 x i8*]* %4, i64 0, i64 1
br label %13
13: ; preds = %28, %9
%14 = phi i32 [ 0, %28 ], [ 1, %9 ]
br label %15
15: ; preds = %13, %22
br label %16
16: ; preds = %15, %19
%17 = call i64 @fgets(i8* %5, i32 256, i32* %7)
%18 = icmp eq i64 %17, 0
br i1 %18, label %31, label %19
19: ; preds = %16
%20 = call i32 @split(i8* %5, i8** %11, i32 256)
%21 = icmp eq i32 %20, 0
br i1 %21, label %16, label %22
22: ; preds = %19
%23 = load i8*, i8** %11
%24 = call i32 @strcmp(i8* dereferenceable(1) %23, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
%26 = icmp sgt i32 %20, 1
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %28, label %15
28: ; preds = %22
%29 = load i8*, i8** %12
%30 = call float @atof(i8* %29)
store float %30, float* %1
br label %13
31: ; preds = %16
%32 = call i32 @fclose(i32* %7)
br label %33
33: ; preds = %2, %31
%34 = phi i32 [ %14, %31 ], [ -1, %2 ]
ret i32 %34
}