#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*/ kprintf(char *, ...);
int /*<<< orphan*/ rled_off();
int /*<<< orphan*/ rled_on();
int xmodem_recv_srec();
void command_load(void) {
  int size;
  rled_on();
  size = xmodem_recv_srec();
  if (size < 0) {
    kprintf("\nXMODEM: failed!\n");
  } else {
    kprintf("\nXMODEM: success!\n");
    kprintf("size = %d\n", size);
  }
  rled_off();
}


x86 assembly (clang, -O0):
<command_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <rled_on@plt>
mov    $0x0,%al
call   1040 <xmodem_recv_srec@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1176 <command_load+0x36>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1060 <kprintf@plt>
jmp    1195 <command_load+0x55>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1060 <kprintf@plt>
mov    -0x4(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1060 <kprintf@plt>
mov    $0x0,%al
call   1050 <rled_off@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_load>:
push   %rbx
xor    %eax,%eax
call   1030 <rled_on@plt>
xor    %eax,%eax
call   1040 <xmodem_recv_srec@plt>
test   %eax,%eax
js     1175 <command_load+0x35>
mov    %eax,%ebx
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1060 <kprintf@plt>
lea    0xebb(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <kprintf@plt>
jmp    1183 <command_load+0x43>
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1060 <kprintf@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <rled_off@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"\0AXMODEM: failed!\0A\00"
@.str.1 = [19 x i8] c"\0AXMODEM: success!\0A\00"
@.str.2 = [11 x i8] c"size = %d\0A\00"
define void @command_load() {
%1 = alloca i32
%2 = call i32 (...) @rled_on()
%3 = call i32 (...) @xmodem_recv_srec()
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %12
8: ; preds = %0
%9 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %8, %6
%13 = call i32 (...) @rled_off()
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"\0AXMODEM: failed!\0A\00"
@.str.1 = [19 x i8] c"\0AXMODEM: success!\0A\00"
@.str.2 = [11 x i8] c"size = %d\0A\00"
define void @command_load() {
%1 = tail call i32 (...) @rled_on()
%2 = tail call i32 (...) @xmodem_recv_srec()
%3 = icmp slt i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %9
6: ; preds = %0
%7 = tail call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %2)
br label %9
9: ; preds = %6, %4
%10 = tail call i32 (...) @rled_off()
ret void
}