#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*/ sprintf(char *, char *);
char *pad_zeros(int zeros_to_pad) {
  static char return_string[1024] = {0};
  char *ptr = return_string;
  int i;
  if (zeros_to_pad <= 0)
    return "";
  for (i = 0; i < zeros_to_pad; i++) {
    ptr += sprintf(ptr, ",z");
  }
  *ptr = '\0';
  return return_string;
}


x86 assembly (clang, -O0):
<pad_zeros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
lea    0x2f1e(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     1140 <pad_zeros+0x30>
lea    0xecb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1193 <pad_zeros+0x83>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1181 <pad_zeros+0x71>
mov    -0x18(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1147 <pad_zeros+0x37>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2eb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pad_zeros>:
test   %edi,%edi
jle    111a <pad_zeros+0x1a>
lea    -0x1(%rdi),%ecx
mov    %edi,%eax
and    $0x3,%eax
cmp    $0x3,%ecx
jae    1122 <pad_zeros+0x22>
lea    0x2f18(%rip),%rcx
jmp    1150 <pad_zeros+0x50>
lea    0xee1(%rip),%rax
ret
and    $0xfffffffc,%edi
lea    0x2f04(%rip),%rcx
movabs $0x7a2c7a2c7a2c7a2c,%rdx
7a 2c 7a
cs nopw 0x0(%rax,%rax,1)
mov    %rdx,(%rcx)
movb   $0x0,0x8(%rcx)
add    $0x8,%rcx
add    $0xfffffffc,%edi
jne    1140 <pad_zeros+0x40>
test   %eax,%eax
je     1172 <pad_zeros+0x72>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x0,0x2(%rcx)
movw   $0x7a2c,(%rcx)
add    $0x2,%rcx
add    $0xffffffff,%eax
jne    1160 <pad_zeros+0x60>
movb   $0x0,(%rcx)
lea    0x2eb4(%rip),%rax
ret

LLVM IR (-O0):
@pad_zeros.return_string = internal global [1024 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c",z\00"
define i8* @pad_zeros(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @pad_zeros.return_string, i64 0, i64 0), i8** %4
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %25
9: ; preds = %1
store i32 0, i32* %5
br label %10
10: ; preds = %20, %9
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8*, i8** %4
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds i8, i8* %17, i64 %18
store i8* %19, i8** %4
br label %20
20: ; preds = %14
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %10
23: ; preds = %10
%24 = load i8*, i8** %4
store i8 0, i8* %24
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @pad_zeros.return_string, i64 0, i64 0), i8** %2
br label %25
25: ; preds = %23, %8
%26 = load i8*, i8** %2
ret i8* %26
}

LLVM IR (-O2):
@pad_zeros.return_string = internal global [1024 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c",z\00"
define i8* @pad_zeros(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %30, label %3
3: ; preds = %1
%4 = add i32 %0, -1
%5 = and i32 %0, 3
%6 = icmp ult i32 %4, 3
br i1 %6, label %18, label %7
7: ; preds = %3
%8 = and i32 %0, -4
br label %9
9: ; preds = %9, %7
%10 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @pad_zeros.return_string, i64 0, i64 0), %7 ], [ %15, %9 ]
%11 = phi i32 [ 0, %7 ], [ %16, %9 ]
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %10, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 3, i1 false)
%12 = getelementptr inbounds i8, i8* %10, i64 2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %12, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 3, i1 false)
%13 = getelementptr inbounds i8, i8* %10, i64 4
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %13, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 3, i1 false)
%14 = getelementptr inbounds i8, i8* %10, i64 6
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %14, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 3, i1 false)
%15 = getelementptr inbounds i8, i8* %10, i64 8
%16 = add i32 %11, 4
%17 = icmp eq i32 %16, %8
br i1 %17, label %18, label %9
18: ; preds = %9, %3
%19 = phi i8* [ undef, %3 ], [ %15, %9 ]
%20 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @pad_zeros.return_string, i64 0, i64 0), %3 ], [ %15, %9 ]
%21 = icmp eq i32 %5, 0
br i1 %21, label %28, label %22
22: ; preds = %18, %22
%23 = phi i8* [ %25, %22 ], [ %20, %18 ]
%24 = phi i32 [ %26, %22 ], [ 0, %18 ]
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %23, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 3, i1 false)
%25 = getelementptr inbounds i8, i8* %23, i64 2
%26 = add i32 %24, 1
%27 = icmp eq i32 %26, %5
br i1 %27, label %28, label %22
28: ; preds = %22, %18
%29 = phi i8* [ %19, %18 ], [ %25, %22 ]
store i8 0, i8* %29
br label %30
30: ; preds = %1, %28
%31 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @pad_zeros.return_string, i64 0, i64 0), %28 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %31
}