#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 *, int);
void palindrome(int key, int times) {
  int i = 1;
  for (; times > 0; times--) {
    for (; i <= key; i++)
      printf("%d", i);
    for (; i > 1; i--)
      printf("%d", i);
  }
}


x86 assembly (clang, -O0):
<palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    119c <palindrome+0x8c>
jmp    1134 <palindrome+0x24>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     115d <palindrome+0x4d>
mov    -0xc(%rbp),%esi
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <palindrome+0x24>
jmp    1162 <palindrome+0x52>
cmpl   $0x1,-0xc(%rbp)
jle    1189 <palindrome+0x79>
mov    -0xc(%rbp),%esi
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1162 <palindrome+0x52>
jmp    118e <palindrome+0x7e>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1125 <palindrome+0x15>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palindrome>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1199 <palindrome+0x89>
mov    %esi,%r15d
mov    %edi,%r14d
lea    0x1(%r14),%r13d
lea    0x2(%r14),%eax
mov    %eax,0x4(%rsp)
mov    $0x1,%ebp
lea    0xec3(%rip),%r12
jmp    114d <palindrome+0x3d>
nop
lea    -0x1(%r15),%eax
cmp    $0x1,%r15d
mov    %eax,%r15d
jle    1199 <palindrome+0x89>
cmp    %r14d,%ebp
jg     1140 <palindrome+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r13d
jne    1160 <palindrome+0x50>
mov    0x4(%rsp),%ebx
mov    %r13d,%ebp
cmp    $0x2,%r13d
jl     1140 <palindrome+0x30>
nop
add    $0xffffffff,%ebx
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
cmp    $0x2,%ebx
ja     1180 <palindrome+0x70>
mov    $0x1,%ebp
jmp    1140 <palindrome+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @palindrome(i32 %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %26
4: ; preds = %2
%5 = add i32 %0, 1
%6 = icmp sgt i32 %5, 1
br label %7
7: ; preds = %4, %22
%8 = phi i32 [ %23, %22 ], [ 1, %4 ]
%9 = phi i32 [ %24, %22 ], [ %1, %4 ]
%10 = icmp sgt i32 %8, %0
br i1 %10, label %22, label %12
11: ; preds = %12
br i1 %6, label %17, label %22
12: ; preds = %7, %12
%13 = phi i32 [ %15, %12 ], [ %8, %7 ]
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = add i32 %13, 1
%16 = icmp eq i32 %13, %0
br i1 %16, label %11, label %12
17: ; preds = %11, %17
%18 = phi i32 [ %20, %17 ], [ %5, %11 ]
%19 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = add nsw i32 %18, -1
%21 = icmp ugt i32 %18, 2
br i1 %21, label %17, label %22
22: ; preds = %17, %7, %11
%23 = phi i32 [ %5, %11 ], [ %8, %7 ], [ 1, %17 ]
%24 = add nsw i32 %9, -1
%25 = icmp sgt i32 %9, 1
br i1 %25, label %7, label %26
26: ; preds = %22, %2
ret void
}