#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 *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
int *getEnumWhoriz(int max) {
  int i;
  char buf[15];
  sprintf(buf, "%d", max);
  int *horizontalSpacingWidth = malloc(sizeof(int) * max);
  int tmp_width;
  const int sep = 3;
  for (i = 1; i <= max; i++) {
    sprintf(buf, "%d", i);
    tmp_width = strlen(buf);
    horizontalSpacingWidth[i] = sep - tmp_width;
  }
  return horizontalSpacingWidth;
}


x86 assembly (clang, -O0):
<getEnumWhoriz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x17(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xeb7(%rip),%rsi
call   1050 <sprintf@plt>
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x3,-0x28(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11bb <getEnumWhoriz+0x8b>
lea    -0x17(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe77(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x17(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    $0x3,%edx
sub    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116f <getEnumWhoriz+0x3f>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getEnumWhoriz>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
lea    0xeb9(%rip),%rsi
lea    0x1(%rsp),%rdi
mov    %r14d,%edx
call   1050 <sprintf@plt>
lea    0x0(,%r14,4),%edi
call   1040 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    11a9 <getEnumWhoriz+0x79>
add    $0x1,%r14d
mov    $0x1,%ebx
lea    0xe87(%rip),%r12
lea    0x1(%rsp),%r13
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    $0x3,%ecx
sub    %eax,%ecx
mov    %ecx,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1180 <getEnumWhoriz+0x50>
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define noalias i32* @getEnumWhoriz(i32 %0) {
%2 = alloca [15 x i8]
%3 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = shl i32 %0, 2
%6 = tail call i32* @malloc(i32 %5)
%7 = icmp slt i32 %0, 1
br i1 %7, label %20, label %8
8: ; preds = %1
%9 = add nuw i32 %0, 1
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %8, %11
%12 = phi i64 [ 1, %8 ], [ %18, %11 ]
%13 = trunc i64 %12 to i32
%14 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @strlen(i8* %3)
%16 = sub nsw i32 3, %15
%17 = getelementptr inbounds i32, i32* %6, i64 %12
store i32 %16, i32* %17
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %20, label %11
20: ; preds = %11, %1
ret i32* %6
}