#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, 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");
  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    0xe8f(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x140(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x240(%rbp),%rdx
mov    -0x28(%rbp),%r8
lea    0xe66(%rip),%rsi
lea    -0x340(%rbp),%rcx
mov    $0x0,%al
call   1030 <fscanf@plt>
mov    -0x38(%rbp),%rdi
lea    -0x240(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1030 <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    0xe26(%rip),%rsi
lea    -0x340(%rbp),%rcx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1030 <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    $0x328,%rsp
mov    %r9,0x18(%rsp)
mov    %r8,%r12
mov    %rcx,0x10(%rsp)
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%rdx
lea    0xea2(%rip),%rsi
lea    0x220(%rsp),%r14
mov    %r14,%rdi
call   1050 <sprintf@plt>
lea    0xe92(%rip),%rsi
mov    %r14,%rdi
call   1040 <fopen@plt>
mov    %rax,%rbx
lea    0xe82(%rip),%rsi
lea    0x120(%rsp),%rbp
lea    0x20(%rsp),%r14
mov    %rax,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1030 <fscanf@plt>
lea    0xe64(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r15,%rcx
mov    %r13,%r8
mov    0x10(%rsp),%r9
xor    %eax,%eax
call   1030 <fscanf@plt>
movups 0x368(%rsp),%xmm0
movups %xmm0,(%rsp)
lea    0xe45(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    0x18(%rsp),%r8
mov    0x360(%rsp),%r9
xor    %eax,%eax
call   1030 <fscanf@plt>
add    $0x328,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s.g20\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"%s %s %d\00"
@.str.3 = [12 x i8] c"%s %d %d %d\00"
@.str.4 = [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 = bitcast [250 x i8]* %21 to i8**
%30 = load i32*, i32** %14
%31 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %29, [250 x i8]* %22, i32* %30)
%32 = load i32*, i32** %19
%33 = bitcast [250 x i8]* %21 to i8**
%34 = load i32*, i32** %11
%35 = load i32*, i32** %12
%36 = load i32*, i32** %13
%37 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %33, i32* %34, i32* %35, i32* %36)
%38 = load i32*, i32** %19
%39 = bitcast [250 x i8]* %21 to i8**
%40 = load double*, double** %15
%41 = load double*, double** %16
%42 = load double*, double** %17
%43 = load double*, double** %18
%44 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %38, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8** %39, [250 x i8]* %22, double* %40, double* %41, double* %42, double* %43)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s.g20\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"%s %s %d\00"
@.str.3 = [12 x i8] c"%s %d %d %d\00"
@.str.4 = [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 = bitcast [250 x i8]* %11 to i8**
%19 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %18, [250 x i8]* %12, i32* %4)
%20 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %18, i32* %1, i32* %2, i32* %3)
%21 = call i32 (i32*, i8*, i8**, ...) @fscanf(i32* %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8** %18, [250 x i8]* %12, double* %5, double* %6, double* %7, double* %8)
ret void
}