#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 */
struct Record {
  int dummy;
};
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ fromLineToRecord(char *, struct Record *);
int getline(char **, size_t *, void *);
char *gzgets(void *, char *, int);
int /*<<< orphan*/ initRecord(struct Record *);
int readNewRecord(void *fileDescriptor, struct Record *record, int isZip) {
  initRecord(record);
  if (isZip == 1) {
    char *readGz;
    char buffer[0x1000];
    readGz = gzgets(fileDescriptor, buffer, 0x1000 - 1);
    if (readGz != 0) {
      fromLineToRecord(buffer, record);
      return 1;
    }
  } else {
    char *line = NULL;
    size_t len = 0;
    ssize_t read;
    read = getline(&line, &len, fileDescriptor);
    if (read != -1) {
      fromLineToRecord(line, record);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<readNewRecord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <initRecord@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    11ae <readNewRecord+0x6e>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
mov    $0xfff,%edx
call   1040 <gzgets@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a9 <readNewRecord+0x69>
lea    -0x1030(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <fromLineToRecord@plt>
movl   $0x1,-0x4(%rbp)
jmp    1216 <readNewRecord+0xd6>
jmp    120f <readNewRecord+0xcf>
movq   $0x0,-0x1038(%rbp)
movq   $0x0,-0x1040(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x1038(%rbp),%rdi
lea    -0x1040(%rbp),%rsi
call   1060 <getline@plt>
mov    %eax,-0x1044(%rbp)
cmpl   $0xffffffff,-0x1044(%rbp)
je     120a <readNewRecord+0xca>
mov    -0x1038(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <fromLineToRecord@plt>
movl   $0x1,-0x4(%rbp)
jmp    1216 <readNewRecord+0xd6>
jmp    120f <readNewRecord+0xcf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readNewRecord>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1010,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <initRecord@plt>
cmp    $0x1,%ebp
jne    117e <readNewRecord+0x3e>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xfff,%edx
call   1040 <gzgets@plt>
test   %rax,%rax
je     11bb <readNewRecord+0x7b>
lea    0x10(%rsp),%rdi
jmp    11ac <readNewRecord+0x6c>
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %rbx,%rdx
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     11bb <readNewRecord+0x7b>
mov    0x10(%rsp),%rdi
mov    %r14,%rsi
call   1030 <fromLineToRecord@plt>
mov    $0x1,%eax
jmp    11bd <readNewRecord+0x7d>
xor    %eax,%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.Record = type { i32 }
define i32 @readNewRecord(i8* %0, %struct.Record* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.Record*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [4096 x i8]
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
store i8* %0, i8** %5
store %struct.Record* %1, %struct.Record** %6
store i32 %2, i32* %7
%13 = load %struct.Record*, %struct.Record** %6
%14 = call i32 @initRecord(%struct.Record* %13)
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %28
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%20 = call i8* @gzgets(i8* %18, i8* %19, i32 4095)
store i8* %20, i8** %8
%21 = load i8*, i8** %8
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%25 = load %struct.Record*, %struct.Record** %6
%26 = call i32 @fromLineToRecord(i8* %24, %struct.Record* %25)
store i32 1, i32* %4
br label %39
27: ; preds = %17
br label %38
28: ; preds = %3
store i8* null, i8** %10
store i64 0, i64* %11
%29 = load i8*, i8** %5
%30 = call i32 @getline(i8** %10, i64* %11, i8* %29)
store i32 %30, i32* %12
%31 = load i32, i32* %12
%32 = icmp ne i32 %31, -1
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i8*, i8** %10
%35 = load %struct.Record*, %struct.Record** %6
%36 = call i32 @fromLineToRecord(i8* %34, %struct.Record* %35)
store i32 1, i32* %4
br label %39
37: ; preds = %28
br label %38
38: ; preds = %37, %27
store i32 0, i32* %4
br label %39
39: ; preds = %38, %33, %23
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
%struct.Record = type { i32 }
define i32 @readNewRecord(i8* %0, %struct.Record* %1, i32 %2) {
%4 = alloca [4096 x i8]
%5 = alloca i8*
%6 = alloca i64
%7 = tail call i32 @initRecord(%struct.Record* %1)
%8 = icmp eq i32 %2, 1
br i1 %8, label %9, label %16
9: ; preds = %3
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%11 = call i8* @gzgets(i8* %0, i8* %10, i32 4095)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %9
br label %25
14: ; preds = %9
%15 = call i32 @fromLineToRecord(i8* %10, %struct.Record* %1)
br label %25
16: ; preds = %3
%17 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%18 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%19 = call i32 @getline(i8** %5, i64* %6, i8* %0)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %22
21: ; preds = %16
br label %25
22: ; preds = %16
%23 = load i8*, i8** %5
%24 = call i32 @fromLineToRecord(i8* %23, %struct.Record* %1)
br label %25
25: ; preds = %13, %21, %22, %14
%26 = phi i32 [ 1, %14 ], [ 1, %22 ], [ 0, %21 ], [ 0, %13 ]
ret i32 %26
}