#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*/ emulcommand(int);
int /*<<< orphan*/ procstr(char *);
int strtoi(char *, char **, int /*<<< orphan*/);
int /*<<< orphan*/ testemul(int, char *);
int /*<<< orphan*/ writeemul(int);
void loadmidi(char *msg) {
  int i;
  procstr(msg);
  while ((msg) && (*msg)) {
    i = strtoi(msg, &msg, 0);
    emulcommand(11);
    writeemul(i);
    testemul(254, "no midi data ACK");
  }
}


x86 assembly (clang, -O0):
<loadmidi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <procstr@plt>
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0xd(%rbp)
je     1185 <loadmidi+0x35>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1195 <loadmidi+0x45>
jmp    11cf <loadmidi+0x7f>
mov    -0x8(%rbp),%rdi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtoi@plt>
mov    %eax,-0xc(%rbp)
mov    $0xb,%edi
call   1050 <emulcommand@plt>
mov    -0xc(%rbp),%edi
call   1070 <writeemul@plt>
mov    $0xfe,%edi
lea    0xe3b(%rip),%rsi
call   1040 <testemul@plt>
jmp    1165 <loadmidi+0x15>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadmidi>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rdi,0x8(%rsp)
call   1060 <procstr@plt>
test   %rbx,%rbx
je     11bc <loadmidi+0x6c>
lea    0x8(%rsp),%r14
lea    0xe89(%rip),%r15
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
je     11bc <loadmidi+0x6c>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <strtoi@plt>
mov    %eax,%ebx
mov    $0xb,%edi
call   1050 <emulcommand@plt>
mov    %ebx,%edi
call   1070 <writeemul@plt>
mov    $0xfe,%edi
mov    %r15,%rsi
call   1040 <testemul@plt>
mov    0x8(%rsp),%rbx
test   %rbx,%rbx
jne    1180 <loadmidi+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"no midi data ACK\00"
define void @loadmidi(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @procstr(i8* %4)
br label %6
6: ; preds = %16, %1
%7 = load i8*, i8** %2
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br label %14
14: ; preds = %9, %6
%15 = phi i1 [ false, %6 ], [ %13, %9 ]
br i1 %15, label %16, label %23
16: ; preds = %14
%17 = load i8*, i8** %2
%18 = call i32 @strtoi(i8* %17, i8** %2, i32 0)
store i32 %18, i32* %3
%19 = call i32 @emulcommand(i32 11)
%20 = load i32, i32* %3
%21 = call i32 @writeemul(i32 %20)
%22 = call i32 @testemul(i32 254, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %6
23: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"no midi data ACK\00"
define void @loadmidi(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = tail call i32 @procstr(i8* %0)
%4 = icmp eq i8* %0, null
br i1 %4, label %16, label %5
5: ; preds = %1, %9
%6 = phi i8* [ %14, %9 ], [ %0, %1 ]
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %5
%10 = call i32 @strtoi(i8* %6, i8** %2, i32 0)
%11 = call i32 @emulcommand(i32 11)
%12 = call i32 @writeemul(i32 %10)
%13 = call i32 @testemul(i32 254, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %2
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %5
16: ; preds = %5, %9, %1
ret void
}