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

/* Variables and functions */
int debug_cmd(int, int);
int rx_ack_chksum(int, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ tx(int /*<<< orphan*/ *, int);
int set_lmm_break(int brknum, uint32_t addr) {
  int err = 0;
  uint8_t rchksum;
  uint8_t pkt[8];
  uint8_t *p = pkt;
  err = debug_cmd(0x80, 5);
  if (err != 0)
    return err;
  *p++ = brknum;
  *p++ = addr & 0xff;
  *p++ = (addr >> 8) & 0xff;
  *p++ = (addr >> 16) & 0xff;
  *p++ = (addr >> 24) & 0xff;
  tx(pkt, 5);
  err = rx_ack_chksum(0xfa, &rchksum, 10000);
  return err;
}


x86 assembly (clang, -O0):
<set_lmm_break>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x80,%edi
mov    $0x5,%esi
call   1040 <debug_cmd@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1174 <set_lmm_break+0x44>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1223 <set_lmm_break+0xf3>
mov    -0x8(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x48(%rbp)
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x48(%rbp)
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x48(%rbp)
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x48(%rbp)
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x48(%rbp)
mov    %ecx,(%rax)
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
call   1050 <tx@plt>
mov    $0xfa,%edi
lea    -0x14(%rbp),%rsi
mov    $0x2710,%edx
call   1030 <rx_ack_chksum@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_lmm_break>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0x80,%edi
mov    $0x5,%esi
call   1040 <debug_cmd@plt>
test   %eax,%eax
jne    1195 <set_lmm_break+0x65>
mov    %ebp,0x10(%rsp)
movzbl %bl,%eax
mov    %eax,0x14(%rsp)
movzbl %bh,%eax
mov    %eax,0x18(%rsp)
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%eax
mov    %eax,0x1c(%rsp)
shr    $0x18,%ebx
mov    %ebx,0x20(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x5,%esi
call   1050 <tx@plt>
lea    0xc(%rsp),%rsi
mov    $0xfa,%edi
mov    $0x2710,%edx
call   1030 <rx_ack_chksum@plt>
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @set_lmm_break(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [8 x i32]
%9 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 0, i32* %6
%10 = getelementptr inbounds [8 x i32], [8 x i32]* %8, i64 0, i64 0
store i32* %10, i32** %9
%11 = call i32 @debug_cmd(i32 128, i32 5)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = load i32, i32* %6
store i32 %15, i32* %3
br label %43
16: ; preds = %2
%17 = load i32, i32* %4
%18 = load i32*, i32** %9
%19 = getelementptr inbounds i32, i32* %18, i32 1
store i32* %19, i32** %9
store i32 %17, i32* %18
%20 = load i32, i32* %5
%21 = and i32 %20, 255
%22 = load i32*, i32** %9
%23 = getelementptr inbounds i32, i32* %22, i32 1
store i32* %23, i32** %9
store i32 %21, i32* %22
%24 = load i32, i32* %5
%25 = ashr i32 %24, 8
%26 = and i32 %25, 255
%27 = load i32*, i32** %9
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %9
store i32 %26, i32* %27
%29 = load i32, i32* %5
%30 = ashr i32 %29, 16
%31 = and i32 %30, 255
%32 = load i32*, i32** %9
%33 = getelementptr inbounds i32, i32* %32, i32 1
store i32* %33, i32** %9
store i32 %31, i32* %32
%34 = load i32, i32* %5
%35 = ashr i32 %34, 24
%36 = and i32 %35, 255
%37 = load i32*, i32** %9
%38 = getelementptr inbounds i32, i32* %37, i32 1
store i32* %38, i32** %9
store i32 %36, i32* %37
%39 = getelementptr inbounds [8 x i32], [8 x i32]* %8, i64 0, i64 0
%40 = call i32 @tx(i32* %39, i32 5)
%41 = call i32 @rx_ack_chksum(i32 250, i32* %7, i32 10000)
store i32 %41, i32* %6
%42 = load i32, i32* %6
store i32 %42, i32* %3
br label %43
43: ; preds = %16, %14
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
define i32 @set_lmm_break(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca [8 x i32]
%5 = bitcast i32* %3 to i8*
%6 = bitcast [8 x i32]* %4 to i8*
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%8 = tail call i32 @debug_cmd(i32 128, i32 5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %2
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 1
store i32 %0, i32* %7
%12 = and i32 %1, 255
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 2
store i32 %12, i32* %11
%14 = lshr i32 %1, 8
%15 = and i32 %14, 255
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 3
store i32 %15, i32* %13
%17 = lshr i32 %1, 16
%18 = and i32 %17, 255
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 4
store i32 %18, i32* %16
%20 = lshr i32 %1, 24
store i32 %20, i32* %19
%21 = call i32 @tx(i32* %7, i32 5)
%22 = call i32 @rx_ack_chksum(i32 250, i32* %3, i32 10000)
br label %23
23: ; preds = %2, %10
%24 = phi i32 [ %22, %10 ], [ %8, %2 ]
ret i32 %24
}