#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 */

/* Variables and functions */
int pic_pe_lookup_file(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
int pic_pe_lookup(char *pathname, const char *file) {
  char filename[(512)];
  snprintf(filename, (512), "%s.bin", file);
  if (pic_pe_lookup_file(pathname, filename) == 0)
    return 0;
  snprintf(filename, (512), "%s.hex", file);
  return pic_pe_lookup_file(pathname, filename);
}


x86 assembly (clang, -O0):
<pic_pe_lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x200,%esi
lea    0xeb6(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1040 <pic_pe_lookup_file@plt>
cmp    $0x0,%eax
jne    1174 <pic_pe_lookup+0x54>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <pic_pe_lookup+0x83>
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x200,%esi
lea    0xe7c(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1040 <pic_pe_lookup_file@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pic_pe_lookup>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xec7(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
call   1030 <snprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <pic_pe_lookup_file@plt>
test   %eax,%eax
je     1182 <pic_pe_lookup+0x62>
lea    0xea5(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
call   1030 <snprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <pic_pe_lookup_file@plt>
jmp    1184 <pic_pe_lookup+0x64>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s.bin\00"
@.str.1 = [7 x i8] c"%s.hex\00"
define i32 @pic_pe_lookup(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [512 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%8 = load i8*, i8** %5
%9 = call i32 @snprintf(i8* %7, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %4
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%12 = call i32 @pic_pe_lookup_file(i8* %10, i8* %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 0, i32* %3
br label %22
15: ; preds = %2
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %5
%18 = call i32 @snprintf(i8* %16, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %4
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%21 = call i32 @pic_pe_lookup_file(i8* %19, i8* %20)
store i32 %21, i32* %3
br label %22
22: ; preds = %15, %14
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s.bin\00"
@.str.1 = [7 x i8] c"%s.hex\00"
define i32 @pic_pe_lookup(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = call i32 @snprintf(i8* %4, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = call i32 @pic_pe_lookup_file(i8* %0, i8* %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = call i32 @snprintf(i8* %4, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%10 = call i32 @pic_pe_lookup_file(i8* %0, i8* %4)
br label %11
11: ; preds = %2, %8
%12 = phi i32 [ %10, %8 ], [ 0, %2 ]
ret i32 %12
}