#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 /*<<< orphan*/ arm_calculate_vector_table_crc();
int err(char *);
scalar_t__ ihex_read_file(char const *);
int lpc_flash_ihex();
int /*<<< orphan*/ lpc_unlock();
int lpc_load_and_flash_ihex(const char *ihex_name) {
  if (ihex_name == NULL) {
    return err("no ihex file"), 0;
  }
  if (ihex_name[0] == '\0') {
    return err("no ihex file"), 0;
  }
  if (ihex_read_file(ihex_name) == 0) {
    return err("ihex file read error"), 0;
  }
  arm_calculate_vector_table_crc();
  lpc_unlock();
  return lpc_flash_ihex();
}


x86 assembly (clang, -O0):
<lpc_load_and_flash_ihex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117f <lpc_load_and_flash_ihex+0x2f>
lea    0xe92(%rip),%rdi
call   1060 <err@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ea <lpc_load_and_flash_ihex+0x9a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a7 <lpc_load_and_flash_ihex+0x57>
lea    0xe6a(%rip),%rdi
call   1060 <err@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ea <lpc_load_and_flash_ihex+0x9a>
mov    -0x10(%rbp),%rdi
call   1030 <ihex_read_file@plt>
cmp    $0x0,%rax
jne    11d2 <lpc_load_and_flash_ihex+0x82>
lea    0xe4c(%rip),%rdi
call   1060 <err@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ea <lpc_load_and_flash_ihex+0x9a>
mov    $0x0,%al
call   1040 <arm_calculate_vector_table_crc@plt>
mov    $0x0,%al
call   1050 <lpc_unlock@plt>
mov    $0x0,%al
call   1070 <lpc_flash_ihex@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lpc_load_and_flash_ihex>:
push   %rax
test   %rdi,%rdi
je     117b <lpc_load_and_flash_ihex+0x2b>
cmpb   $0x0,(%rdi)
je     117b <lpc_load_and_flash_ihex+0x2b>
call   1030 <ihex_read_file@plt>
test   %rax,%rax
je     1184 <lpc_load_and_flash_ihex+0x34>
xor    %eax,%eax
call   1040 <arm_calculate_vector_table_crc@plt>
xor    %eax,%eax
call   1050 <lpc_unlock@plt>
xor    %eax,%eax
pop    %rcx
jmp    1070 <lpc_flash_ihex@plt>
lea    0xe7e(%rip),%rdi
jmp    118b <lpc_load_and_flash_ihex+0x3b>
lea    0xe82(%rip),%rdi
call   1060 <err@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"no ihex file\00"
@.str.1 = [21 x i8] c"ihex file read error\00"
define i32 @lpc_load_and_flash_ihex(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @err(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %26
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = call i32 @err(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %26
16: ; preds = %8
%17 = load i8*, i8** %3
%18 = call i64 @ihex_read_file(i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @err(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %26
22: ; preds = %16
%23 = call i32 (...) @arm_calculate_vector_table_crc()
%24 = call i32 (...) @lpc_unlock()
%25 = call i32 (...) @lpc_flash_ihex()
store i32 %25, i32* %2
br label %26
26: ; preds = %22, %20, %14, %6
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@.str = [13 x i8] c"no ihex file\00"
@.str.1 = [21 x i8] c"ihex file read error\00"
define i32 @lpc_load_and_flash_ihex(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @err(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %19
5: ; preds = %1
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @err(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %19
10: ; preds = %5
%11 = tail call i64 @ihex_read_file(i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @err(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %19
15: ; preds = %10
%16 = tail call i32 (...) @arm_calculate_vector_table_crc()
%17 = tail call i32 (...) @lpc_unlock()
%18 = tail call i32 (...) @lpc_flash_ihex()
br label %19
19: ; preds = %15, %13, %8, %3
%20 = phi i32 [ 0, %3 ], [ 0, %8 ], [ 0, %13 ], [ %18, %15 ]
ret i32 %20
}