#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 uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ getentry(int /*<<< orphan*/ *, char *);
uint8_t getrecord(FILE *fd_user, char *username, FILE *fd_pass,
                  char *password) {
  getentry(fd_pass, password);
  if (password[0] == '\0') {
    getentry(fd_user, username);
    if (username[0] == '\0')
      return (1);
    else if (username[0] != '\0') {
      fseek(fd_pass, 0, SEEK_SET);
      getentry(fd_pass, password);
    } else
      return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<getrecord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <getentry@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ca <getrecord+0xaa>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <getentry@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117e <getrecord+0x5e>
movl   $0x1,-0x4(%rbp)
jmp    11d1 <getrecord+0xb1>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b4 <getrecord+0x94>
mov    -0x20(%rbp),%rdi
mov    0x2e47(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1030 <fseek@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <getentry@plt>
jmp    11c0 <getrecord+0xa0>
movl   $0x1,-0x4(%rbp)
jmp    11d1 <getrecord+0xb1>
jmp    11c5 <getrecord+0xa5>
jmp    11ca <getrecord+0xaa>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getrecord>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rdx,%rdi
mov    %rcx,%rsi
call   1040 <getentry@plt>
xor    %ebp,%ebp
cmpb   $0x0,(%rbx)
jne    117e <getrecord+0x5e>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <getentry@plt>
cmpb   $0x0,(%r15)
je     1179 <getrecord+0x59>
mov    0x2e82(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <fseek@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <getentry@plt>
jmp    117e <getrecord+0x5e>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @getrecord(i32* %0, i8* %1, i32* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8*
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
%10 = load i32*, i32** %8
%11 = load i8*, i8** %9
%12 = call i32 @getentry(i32* %10, i8* %11)
%13 = load i8*, i8** %9
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %44
18: ; preds = %4
%19 = load i32*, i32** %6
%20 = load i8*, i8** %7
%21 = call i32 @getentry(i32* %19, i8* %20)
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %18
store i32 1, i32* %5
br label %45
28: ; preds = %18
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %28
%35 = load i32*, i32** %8
%36 = load i32, i32* @SEEK_SET
%37 = call i32 @fseek(i32* %35, i32 0, i32 %36)
%38 = load i32*, i32** %8
%39 = load i8*, i8** %9
%40 = call i32 @getentry(i32* %38, i8* %39)
br label %42
41: ; preds = %28
store i32 1, i32* %5
br label %45
42: ; preds = %34
br label %43
43: ; preds = %42
br label %44
44: ; preds = %43, %4
store i32 0, i32* %5
br label %45
45: ; preds = %44, %41, %27
%46 = load i32, i32* %5
ret i32 %46
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @getrecord(i32* %0, i8* %1, i32* %2, i8* %3) {
%5 = tail call i32 @getentry(i32* %2, i8* %3)
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %4
%9 = tail call i32 @getentry(i32* %0, i8* %1)
%10 = load i8, i8* %1
%11 = icmp eq i8 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i32, i32* @SEEK_SET
%14 = tail call i32 @fseek(i32* %2, i32 0, i32 %13)
%15 = tail call i32 @getentry(i32* %2, i8* %3)
br label %16
16: ; preds = %4, %12, %8
%17 = phi i32 [ 1, %8 ], [ 0, %12 ], [ 0, %4 ]
ret i32 %17
}