#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 *, ...);
void print_elem(int elem, int space) {
  int p = 10, i = 1;
  while (elem > p) {
    i++;
    p *= 10;
  }
  for (int j = 0; j < (space - i) / 2 + (space - i) % 2; j++)
    printf(" ");
  printf("%d", elem);
  for (int j = 0; j < (space - i) / 2; j++)
    printf(" ");
}


x86 assembly (clang, -O0):
<print_elem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    114d <print_elem+0x3d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    112c <print_elem+0x1c>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    -0x1c(%rbp),%eax
add    %edx,%ecx
cmp    %ecx,%eax
jge    11a1 <print_elem+0x91>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <print_elem+0x44>
mov    -0x4(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11f6 <print_elem+0xe6>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b9 <print_elem+0xa9>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_elem>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r15d
mov    $0x1,%eax
cmp    $0xb,%edi
jl     115d <print_elem+0x3d>
mov    $0xa,%ecx
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%eax
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
cmp    %r15d,%ecx
jl     1150 <print_elem+0x30>
sub    %eax,%r14d
mov    %r14d,%eax
shr    $0x1f,%eax
add    %r14d,%eax
mov    %eax,%ebx
sar    %ebx
and    $0xfffffffe,%eax
mov    %r14d,%ebp
sub    %eax,%ebp
add    %ebx,%ebp
test   %ebp,%ebp
jle    118f <print_elem+0x6f>
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1180 <print_elem+0x60>
lea    0xe6a(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%r14d
jl     11bf <print_elem+0x9f>
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11b0 <print_elem+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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