#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*/ printf(char *, char const *, int, ...);
void printConst(const char *type, int idx, int len, int isglobal) {
  if (!isglobal) {
    if (len > 0) {
      printf("%s* getelementptr ([%d x %s], [%d x %s]* %%cmd%d, i32 0, i32 0)",
             type, len, type, len, type, idx);
    } else {
      printf("%s %%cmd%d", type, idx);
    }
  } else {
    if (len > 0) {
      printf("%s* getelementptr ([%d x %s], [%d x %s]* @cmd%d, i32 0, i32 0)",
             type, len, type, len, type, idx);
    } else {
      printf("%s @cmd%d", type, idx);
    }
  }
}


x86 assembly (clang, -O0):
<printConst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    117f <printConst+0x6f>
cmpl   $0x0,-0x10(%rbp)
jle    1165 <printConst+0x55>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8d
mov    -0x8(%rbp),%r9
mov    -0xc(%rbp),%eax
lea    0xeaa(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117a <printConst+0x6a>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cf <printConst+0xbf>
cmpl   $0x0,-0x10(%rbp)
jle    11b5 <printConst+0xa5>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8d
mov    -0x8(%rbp),%r9
mov    -0xc(%rbp),%eax
lea    0xea5(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ca <printConst+0xba>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cf <printConst+0xbf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printConst>:
push   %rax
mov    %esi,%eax
mov    %rdi,%rsi
test   %ecx,%ecx
je     112a <printConst+0x1a>
test   %edx,%edx
jle    114a <printConst+0x3a>
mov    %eax,(%rsp)
lea    0xf23(%rip),%rdi
jmp    1138 <printConst+0x28>
test   %edx,%edx
jle    1153 <printConst+0x43>
mov    %eax,(%rsp)
lea    0xec8(%rip),%rdi
mov    %rsi,%rcx
mov    %edx,%r8d
mov    %rsi,%r9
xor    %eax,%eax
call   1030 <printf@plt>
pop    %rax
ret
lea    0xf39(%rip),%rdi
jmp    115a <printConst+0x4a>
lea    0xee6(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
pop    %rcx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [64 x i8] c"%s* getelementptr ([%d x %s], [%d x %s]* %%cmd%d, i32 0, i32 0)\00"
@.str.1 = [11 x i8] c"%s %%cmd%d\00"
@.str.2 = [63 x i8] c"%s* getelementptr ([%d x %s], [%d x %s]* @cmd%d, i32 0, i32 0)\00"
@.str.3 = [10 x i8] c"%s @cmd%d\00"
define void @printConst(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
%10 = icmp ne i32 %9, 0
br i1 %10, label %27, label %11
11: ; preds = %4
%12 = load i32, i32* %7
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = load i32, i32* %7
%17 = load i8*, i8** %5
%18 = load i32, i32* %7
%19 = load i8*, i8** %5
%20 = load i32, i32* %6
%21 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %15, i32 %16, i8* %17, i32 %18, i8* %19, i32 %20)
br label %26
22: ; preds = %11
%23 = load i8*, i8** %5
%24 = load i32, i32* %6
%25 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %24)
br label %26
26: ; preds = %22, %14
br label %43
27: ; preds = %4
%28 = load i32, i32* %7
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %27
%31 = load i8*, i8** %5
%32 = load i32, i32* %7
%33 = load i8*, i8** %5
%34 = load i32, i32* %7
%35 = load i8*, i8** %5
%36 = load i32, i32* %6
%37 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %31, i32 %32, i8* %33, i32 %34, i8* %35, i32 %36)
br label %42
38: ; preds = %27
%39 = load i8*, i8** %5
%40 = load i32, i32* %6
%41 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %39, i32 %40)
br label %42
42: ; preds = %38, %30
br label %43
43: ; preds = %42, %26
ret void
}

LLVM IR (-O2):
@.str = [64 x i8] c"%s* getelementptr ([%d x %s], [%d x %s]* %%cmd%d, i32 0, i32 0)\00"
@.str.1 = [11 x i8] c"%s %%cmd%d\00"
@.str.2 = [63 x i8] c"%s* getelementptr ([%d x %s], [%d x %s]* @cmd%d, i32 0, i32 0)\00"
@.str.3 = [10 x i8] c"%s @cmd%d\00"
define void @printConst(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
%6 = icmp sgt i32 %2, 0
br i1 %5, label %7, label %12
7: ; preds = %4
br i1 %6, label %8, label %10
8: ; preds = %7
%9 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2, i8* %0, i32 %2, i8* %0, i32 %1)
br label %17
10: ; preds = %7
%11 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %1)
br label %17
12: ; preds = %4
br i1 %6, label %13, label %15
13: ; preds = %12
%14 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %2, i8* %0, i32 %2, i8* %0, i32 %1)
br label %17
15: ; preds = %12
%16 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %1)
br label %17
17: ; preds = %13, %15, %8, %10
ret void
}