#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 */
char *inst_2_str(int);
int inst_has_argu(int);
int /*<<< orphan*/ printf(char *, ...);
int print_spec_text(int *cur_text) {
  int has_argu = 0;
  const char *inst_str = inst_2_str(*cur_text);
  has_argu = inst_has_argu(*cur_text);
  if (inst_str)
    printf("addr %p ## %s", cur_text, inst_str);
  else
    printf("addr %p ## %x", cur_text, *cur_text);
  if (has_argu) {
    ++cur_text;
    printf(" %#x(%d)", *cur_text, *cur_text);
  }
  printf("\n");
  return has_argu;
}


x86 assembly (clang, -O0):
<print_spec_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1050 <inst_2_str@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1040 <inst_has_argu@plt>
mov    %eax,-0xc(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1186 <print_spec_text+0x56>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <print_spec_text+0x6e>
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
je     11ce <print_spec_text+0x9e>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_spec_text>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1060 <inst_2_str@plt>
mov    %rax,%rbp
mov    (%rbx),%edi
call   1050 <inst_has_argu@plt>
mov    %eax,%r14d
test   %rbp,%rbp
je     119e <print_spec_text+0x5e>
lea    0xe99(%rip),%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
je     118c <print_spec_text+0x4c>
mov    0x4(%rbx),%edx
lea    0xe99(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%rbx),%edx
lea    0xe67(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
jne    1179 <print_spec_text+0x39>
jmp    118c <print_spec_text+0x4c>

LLVM IR (-O0):
@.str = [14 x i8] c"addr %p ## %s\00"
@.str.1 = [14 x i8] c"addr %p ## %x\00"
@.str.2 = [9 x i8] c" %#x(%d)\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @print_spec_text(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
store i32* %0, i32** %2
store i32 0, i32* %3
%5 = load i32*, i32** %2
%6 = load i32, i32* %5
%7 = call i8* @inst_2_str(i32 %6)
store i8* %7, i8** %4
%8 = load i32*, i32** %2
%9 = load i32, i32* %8
%10 = call i32 @inst_has_argu(i32 %9)
store i32 %10, i32* %3
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i32*, i32** %2
%15 = load i8*, i8** %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32* %14, i8* %15)
br label %22
17: ; preds = %1
%18 = load i32*, i32** %2
%19 = load i32*, i32** %2
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %18, i32 %20)
br label %22
22: ; preds = %17, %13
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = load i32*, i32** %2
%27 = getelementptr inbounds i32, i32* %26, i32 1
store i32* %27, i32** %2
%28 = load i32*, i32** %2
%29 = load i32, i32* %28
%30 = load i32*, i32** %2
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %31)
br label %33
33: ; preds = %25, %22
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [14 x i8] c"addr %p ## %s\00"
@.str.1 = [14 x i8] c"addr %p ## %x\00"
@.str.2 = [9 x i8] c" %#x(%d)\00"
define i32 @print_spec_text(i32* %0) {
%2 = load i32, i32* %0
%3 = tail call i8* @inst_2_str(i32 %2)
%4 = load i32, i32* %0
%5 = tail call i32 @inst_has_argu(i32 %4)
%6 = icmp eq i8* %3, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32* %0, i8* %3)
br label %12
9: ; preds = %1
%10 = load i32, i32* %0
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %0, i32 %10)
br label %12
12: ; preds = %9, %7
%13 = icmp eq i32 %5, 0
br i1 %13, label %18, label %14
14: ; preds = %12
%15 = getelementptr inbounds i32, i32* %0, i64 1
%16 = load i32, i32* %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %16)
br label %18
18: ; preds = %14, %12
%19 = tail call i32 @putchar(i32 10)
ret i32 %5
}