#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*/ add_opcode(int, int);
int begin_function(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void nop(int opcode) {
  char func_name[(100)];
  int func_id;
  if (opcode != 0x4E71)
    return;
  sprintf(func_name, "nop_%04X", opcode);
  func_id = begin_function(func_name);
  printf("\tFETCH_OPCODE;\n}\n\n");
  add_opcode(func_id, opcode);
}


x86 assembly (clang, -O0):
<nop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x4e71,-0x4(%rbp)
je     1160 <nop+0x20>
jmp    1196 <nop+0x56>
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe92(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x70(%rbp),%rdi
call   1060 <begin_function@plt>
mov    %eax,-0x74(%rbp)
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x74(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <add_opcode@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nop>:
cmp    $0x4e71,%edi
jne    118b <nop+0x4b>
push   %rbx
sub    $0x70,%rsp
lea    0xeac(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x4e71,%edx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <begin_function@plt>
mov    %eax,%ebx
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    $0x4e71,%esi
call   1040 <add_opcode@plt>
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"nop_%04X\00"
@.str.1 = [19 x i8] c"\09FETCH_OPCODE;\0A}\0A\0A\00"
define void @nop(i32 %0) {
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 20081
br i1 %6, label %7, label %8
7: ; preds = %1
br label %18
8: ; preds = %1
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = load i32, i32* %2
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = call i32 @begin_function(i8* %12)
store i32 %13, i32* %4
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = call i32 @add_opcode(i32 %15, i32 %16)
br label %18
18: ; preds = %8, %7
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"nop_%04X\00"
@str = [18 x i8] c"\09FETCH_OPCODE;\0A}\0A\00"
define void @nop(i32 %0) {
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32 %0, 20081
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 20081)
%7 = call i32 @begin_function(i8* %3)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%9 = call i32 @add_opcode(i32 %7, i32 20081)
br label %10
10: ; preds = %1, %5
ret void
}