#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*/ printf(char *, int);
int reademul();
int /*<<< orphan*/ testemul(int, char *);
int /*<<< orphan*/ writeemul(int);
void showemul(int i) {
  int j;
  emulcommand(5);
  writeemul(i);
  testemul(254, "no info ACK");
  printf("Emulator info string %d:", i);
  do {
    j = reademul();
    if (j == 255)
      break;
    printf("%c", j);
  } while (j != 10);
}


x86 assembly (clang, -O0):
<showemul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x5,%edi
call   1060 <emulcommand@plt>
mov    -0x4(%rbp),%edi
call   1070 <writeemul@plt>
mov    $0xfe,%edi
lea    0xe87(%rip),%rsi
call   1050 <testemul@plt>
mov    -0x4(%rbp),%esi
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <reademul@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xff,-0x8(%rbp)
jne    11a9 <showemul+0x59>
jmp    11c2 <showemul+0x72>
mov    -0x8(%rbp),%esi
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xa,-0x8(%rbp)
jne    118d <showemul+0x3d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showemul>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x5,%edi
call   1060 <emulcommand@plt>
mov    %ebx,%edi
call   1070 <writeemul@plt>
lea    0xe93(%rip),%rsi
mov    $0xfe,%edi
call   1050 <testemul@plt>
lea    0xe8e(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
lea    0xe99(%rip),%rbx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <reademul@plt>
cmp    $0xff,%eax
je     11af <showemul+0x5f>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
cmp    $0xa,%ebp
jne    1190 <showemul+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"no info ACK\00"
@.str.1 = [25 x i8] c"Emulator info string %d:\00"
@.str.2 = [3 x i8] c"%c\00"
define void @showemul(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @emulcommand(i32 5)
%5 = load i32, i32* %2
%6 = call i32 @writeemul(i32 %5)
%7 = call i32 @testemul(i32 254, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %18, %1
%11 = call i32 (...) @reademul()
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 255
br i1 %13, label %14, label %15
14: ; preds = %10
br label %21
15: ; preds = %10
%16 = load i32, i32* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 10
br i1 %20, label %10, label %21
21: ; preds = %18, %14
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"no info ACK\00"
@.str.1 = [25 x i8] c"Emulator info string %d:\00"
@.str.2 = [3 x i8] c"%c\00"
define void @showemul(i32 %0) {
%2 = tail call i32 @emulcommand(i32 5)
%3 = tail call i32 @writeemul(i32 %0)
%4 = tail call i32 @testemul(i32 254, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %6
6: ; preds = %9, %1
%7 = tail call i32 (...) @reademul()
%8 = icmp eq i32 %7, 255
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%11 = icmp eq i32 %7, 10
br i1 %11, label %12, label %6
12: ; preds = %6, %9
ret void
}