#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*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char **, ...);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
void read_header(char *rootname, int *nx, int *ny, int *nz, int *nevents,
                 double *xOff, double *yOff, double *zOff, double *scale) {
  FILE *in;
  char fname[250];
  char dum1[250], dum2[250];
  sprintf(fname, "%s.g20", rootname);
  in = fopen(fname, "r");
  if (in == NULL) {
    printf("Error: Could not open noddy header file at %s\n", rootname);
    exit(1);
  }
  fscanf(in, "%s %s %d", &dum1, &dum2, nevents);
  fscanf(in, "%s %d %d %d", &dum1, nx, ny, nz);
  fscanf(in, "%s %s %lf %lf %lf %lf", &dum1, &dum2, xOff, yOff, zOff, scale);
}


x86 assembly (clang, -O0):
<read_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x140(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe6f(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x140(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11d2 <read_header+0x82>
mov    -0x8(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x38(%rbp),%rdi
lea    -0x240(%rbp),%rdx
mov    -0x28(%rbp),%r8
lea    0xe50(%rip),%rsi
lea    -0x340(%rbp),%rcx
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x38(%rbp),%rdi
lea    -0x240(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x38(%rbp),%rdi
lea    -0x240(%rbp),%rdx
mov    -0x30(%rbp),%r8
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%rax
lea    0xe10(%rip),%rsi
lea    -0x340(%rbp),%rcx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1040 <fscanf@plt>
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_header>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x318,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,%r15
mov    %rcx,(%rsp)
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%r14
lea    0xe83(%rip),%rsi
lea    0x210(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rdx
call   1060 <sprintf@plt>
lea    0xe70(%rip),%rsi
mov    %rbp,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     1234 <read_header+0xe4>
mov    %rax,%rbp
lea    0xe86(%rip),%rsi
lea    0x110(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1040 <fscanf@plt>
lea    0xe68(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r12,%r8
mov    (%rsp),%r9
xor    %eax,%eax
call   1040 <fscanf@plt>
lea    0xe56(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    0x8(%rsp),%r8
mov    0x350(%rsp),%r9
xor    %eax,%eax
push   0x360(%rsp)
push   0x360(%rsp)
call   1040 <fscanf@plt>
add    $0x328,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdce(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%s.g20\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [47 x i8] c"Error: Could not open noddy header file at %s\0A\00"
@.str.3 = [9 x i8] c"%s %s %d\00"
@.str.4 = [12 x i8] c"%s %d %d %d\00"
@.str.5 = [22 x i8] c"%s %s %lf %lf %lf %lf\00"
define void @read_header(i8* %0, i32* %1, i32* %2, i32* %3, i32* %4, double* %5, double* %6, double* %7, double* %8) {
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca i32*
%20 = alloca [250 x i8]
%21 = alloca [250 x i8]
%22 = alloca [250 x i8]
store i8* %0, i8** %10
store i32* %1, i32** %11
store i32* %2, i32** %12
store i32* %3, i32** %13
store i32* %4, i32** %14
store double* %5, double** %15
store double* %6, double** %16
store double* %7, double** %17
store double* %8, double** %18
%23 = getelementptr inbounds [250 x i8], [250 x i8]* %20, i64 0, i64 0
%24 = load i8*, i8** %10
%25 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [250 x i8], [250 x i8]* %20, i64 0, i64 0
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %19
%28 = load i32*, i32** %19
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %34
30: ; preds = %9
%31 = load i8*, i8** %10
%32 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %9
%35 = load i32*, i32** %19
%36 = bitcast [250 x i8]* %21 to i8**
%37 = load i32*, i32** %14
%38 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %36, [250 x i8]* %22, i32* %37)
%39 = load i32*, i32** %19
%40 = bitcast [250 x i8]* %21 to i8**
%41 = load i32*, i32** %11
%42 = load i32*, i32** %12
%43 = load i32*, i32** %13
%44 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %39, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8** %40, i32* %41, i32* %42, i32* %43)
%45 = load i32*, i32** %19
%46 = bitcast [250 x i8]* %21 to i8**
%47 = load double*, double** %15
%48 = load double*, double** %16
%49 = load double*, double** %17
%50 = load double*, double** %18
%51 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %45, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8** %46, [250 x i8]* %22, double* %47, double* %48, double* %49, double* %50)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s.g20\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [47 x i8] c"Error: Could not open noddy header file at %s\0A\00"
@.str.3 = [9 x i8] c"%s %s %d\00"
@.str.4 = [12 x i8] c"%s %d %d %d\00"
@.str.5 = [22 x i8] c"%s %s %lf %lf %lf %lf\00"
define void @read_header(i8* %0, i32* %1, i32* %2, i32* %3, i32* %4, double* %5, double* %6, double* %7, double* %8) {
%10 = alloca [250 x i8]
%11 = alloca [250 x i8]
%12 = alloca [250 x i8]
%13 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%14 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%15 = getelementptr inbounds [250 x i8], [250 x i8]* %12, i64 0, i64 0
%16 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
%17 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %9
%20 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %9
%23 = bitcast [250 x i8]* %11 to i8**
%24 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %23, [250 x i8]* %12, i32* %4)
%25 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8** %23, i32* %1, i32* %2, i32* %3)
%26 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8** %23, [250 x i8]* %12, double* %5, double* %6, double* %7, double* %8)
ret void
}