#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*/ errr(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int split(char *, char **, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ t4_init(float *);
scalar_t__ t4_read1(int /*<<< orphan*/ *, float *);
int t4_read(char *t4file, float *t4) {
  FILE *fp;
  char string[256], *srgv[256];
  int m;
  int done;
  if (!(fp = fopen(t4file, "r"))) {
    fprintf(stderr, "%s read error; transform initialized to I4\n", t4file);
    t4_init(t4);
    return 1;
  }
  printf("Reading: %s\n", t4file);
  done = 0;
  while (fgets(string, 256, fp)) {
    if (!(m = split(string, srgv, 256)))
      continue;
    if (m == 1 && !strcmp(srgv[0], "t4")) {
      if (t4_read1(fp, t4))
        errr("t4_read", t4file);
      done++;
    }
  }
  if (!done) {
    rewind(fp);
    if (t4_read1(fp, t4))
      errr("t4_read", t4file);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<t4_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x930,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    120f <t4_read+0x5f>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe0d(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <t4_init@plt>
movl   $0x1,-0x4(%rbp)
jmp    132a <t4_read+0x17a>
mov    -0x10(%rbp),%rsi
lea    0xe14(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x928(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     12d8 <t4_read+0x128>
lea    -0x120(%rbp),%rdi
lea    -0x920(%rbp),%rsi
mov    $0x100,%edx
call   1070 <split@plt>
mov    %eax,-0x924(%rbp)
cmp    $0x0,%eax
jne    1274 <t4_read+0xc4>
jmp    1229 <t4_read+0x79>
cmpl   $0x1,-0x924(%rbp)
jne    12d3 <t4_read+0x123>
mov    -0x920(%rbp),%rdi
lea    0xdac(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    12d3 <t4_read+0x123>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <t4_read1@plt>
cmp    $0x0,%rax
je     12c4 <t4_read+0x114>
mov    -0x10(%rbp),%rsi
lea    0xd7f(%rip),%rdi
call   10c0 <errr@plt>
mov    -0x928(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x928(%rbp)
jmp    1229 <t4_read+0x79>
cmpl   $0x0,-0x928(%rbp)
jne    131a <t4_read+0x16a>
mov    -0x20(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <t4_read1@plt>
cmp    $0x0,%rax
je     1315 <t4_read+0x165>
mov    -0x10(%rbp),%rsi
lea    0xd2e(%rip),%rdi
call   10c0 <errr@plt>
jmp    131a <t4_read+0x16a>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x930,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t4_read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x908,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe32(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12a1 <t4_read+0xf1>
mov    %rax,%r12
lea    0xe48(%rip),%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
xor    %ebp,%ebp
mov    %rsp,%rbx
lea    0x100(%rsp),%r13
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     126a <t4_read+0xba>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
call   1070 <split@plt>
test   %eax,%eax
je     1200 <t4_read+0x50>
cmp    $0x1,%eax
jne    1200 <t4_read+0x50>
mov    0x100(%rsp),%rdi
lea    0xdfe(%rip),%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
jne    1200 <t4_read+0x50>
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <t4_read1@plt>
test   %rax,%rax
je     1265 <t4_read+0xb5>
lea    0xde1(%rip),%rdi
mov    %r15,%rsi
call   10c0 <errr@plt>
add    $0x1,%ebp
jmp    1200 <t4_read+0x50>
test   %ebp,%ebp
jne    1295 <t4_read+0xe5>
mov    %r12,%rdi
call   1060 <rewind@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <t4_read1@plt>
test   %rax,%rax
je     1295 <t4_read+0xe5>
lea    0xdb1(%rip),%rdi
mov    %r15,%rsi
call   10c0 <errr@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    12c6 <t4_read+0x116>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
mov    %r15,%rdx
call   10a0 <fprintf@plt>
mov    %r14,%rdi
call   10d0 <t4_init@plt>
mov    $0x1,%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"
@stderr = global i32 0
@.str.1 = [44 x i8] c"%s read error; transform initialized to I4\0A\00"
@.str.2 = [13 x i8] c"Reading: %s\0A\00"
@.str.3 = [3 x i8] c"t4\00"
@.str.4 = [8 x i8] c"t4_read\00"
define i32 @t4_read(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 i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %6
%13 = icmp ne i32* %12, null
br i1 %13, label %20, label %14
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %4
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load float*, float** %5
%19 = call i32 @t4_init(float* %18)
store i32 1, i32* %3
br label %71
20: ; preds = %2
%21 = load i8*, i8** %4
%22 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %21)
store i32 0, i32* %10
br label %23
23: ; preds = %53, %33, %20
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%25 = load i32*, i32** %6
%26 = call i64 @fgets(i8* %24, i32 256, i32* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %54
28: ; preds = %23
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%30 = getelementptr inbounds [256 x i8*], [256 x i8*]* %8, i64 0, i64 0
%31 = call i32 @split(i8* %29, i8** %30, i32 256)
store i32 %31, i32* %9
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %28
br label %23
34: ; preds = %28
%35 = load i32, i32* %9
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %53
37: ; preds = %34
%38 = getelementptr inbounds [256 x i8*], [256 x i8*]* %8, i64 0, i64 0
%39 = load i8*, i8** %38
%40 = call i32 @strcmp(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp ne i32 %40, 0
br i1 %41, label %53, label %42
42: ; preds = %37
%43 = load i32*, i32** %6
%44 = load float*, float** %5
%45 = call i64 @t4_read1(i32* %43, float* %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %42
%48 = load i8*, i8** %4
%49 = call i32 @errr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %47, %42
%51 = load i32, i32* %10
%52 = add nsw i32 %51, 1
store i32 %52, i32* %10
br label %53
53: ; preds = %50, %37, %34
br label %23
54: ; preds = %23
%55 = load i32, i32* %10
%56 = icmp ne i32 %55, 0
br i1 %56, label %68, label %57
57: ; preds = %54
%58 = load i32*, i32** %6
%59 = call i32 @rewind(i32* %58)
%60 = load i32*, i32** %6
%61 = load float*, float** %5
%62 = call i64 @t4_read1(i32* %60, float* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %57
%65 = load i8*, i8** %4
%66 = call i32 @errr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %64, %57
br label %68
68: ; preds = %67, %54
%69 = load i32*, i32** %6
%70 = call i32 @fclose(i32* %69)
store i32 0, i32* %3
br label %71
71: ; preds = %68, %14
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [44 x i8] c"%s read error; transform initialized to I4\0A\00"
@.str.2 = [13 x i8] c"Reading: %s\0A\00"
@.str.3 = [3 x i8] c"t4\00"
@.str.4 = [8 x i8] c"t4_read\00"
define i32 @t4_read(i8* %0, float* %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*
%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 %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = tail call i32 @t4_init(float* %1)
br label %46
13: ; preds = %2
%14 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%15 = getelementptr inbounds [256 x i8*], [256 x i8*]* %4, i64 0, i64 0
br label %16
16: ; preds = %34, %13
%17 = phi i32 [ %35, %34 ], [ 0, %13 ]
br label %18
18: ; preds = %28, %16
br label %19
19: ; preds = %18, %22
%20 = call i64 @fgets(i8* %5, i32 256, i32* %7)
%21 = icmp eq i64 %20, 0
br i1 %21, label %36, label %22
22: ; preds = %19
%23 = call i32 @split(i8* %5, i8** %15, i32 256)
switch i32 %23, label %28 [
i32 0, label %19
i32 1, label %24
]
24: ; preds = %22
%25 = load i8*, i8** %15
%26 = call i32 @strcmp(i8* dereferenceable(1) %25, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %22, %24
br label %18
29: ; preds = %24
%30 = call i64 @t4_read1(i32* %7, float* %1)
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = call i32 @errr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %34
34: ; preds = %32, %29
%35 = add nuw nsw i32 %17, 1
br label %16
36: ; preds = %19
%37 = icmp eq i32 %17, 0
br i1 %37, label %38, label %44
38: ; preds = %36
%39 = call i32 @rewind(i32* %7)
%40 = call i64 @t4_read1(i32* %7, float* %1)
%41 = icmp eq i64 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %38
%43 = call i32 @errr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %44
44: ; preds = %38, %42, %36
%45 = call i32 @fclose(i32* %7)
br label %46
46: ; preds = %44, %9
%47 = phi i32 [ 0, %44 ], [ 1, %9 ]
ret i32 %47
}