#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 *, int);
char *strcat(char *, char *);
int /*<<< orphan*/ strlen(char *);
int syscon_add_symbol(int /*<<< orphan*/, char *);
int padcon_add_symbols(int m) {
  char nbr[10];
  char name[20];
  int idx, fail;
  for (idx = 1; idx <= m; idx++) {
    name[0] = 'Z';
    name[1] = '\0';
    sprintf(nbr, "%d", idx);
    char *ptr = strcat(name, nbr);
    fail = syscon_add_symbol(strlen(name), name);
  }
  return fail;
}


x86 assembly (clang, -O0):
<padcon_add_symbols>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11af <padcon_add_symbols+0x6f>
movb   $0x5a,-0x30(%rbp)
movb   $0x0,-0x2f(%rbp)
lea    -0xe(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xe8c(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    -0xe(%rbp),%rsi
call   1050 <strcat@plt>
mov    %rax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
call   1040 <syscon_add_symbol@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1152 <padcon_add_symbols+0x12>
mov    -0x38(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<padcon_add_symbols>:
test   %edi,%edi
jle    11c1 <padcon_add_symbols+0x81>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %edi,%r15d
neg    %r15d
mov    $0x1,%ebx
lea    0xe9d(%rip),%r14
lea    0x16(%rsp),%r12
mov    %rsp,%r13
nopl   0x0(%rax,%rax,1)
movw   $0x5a,(%rsp)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1060 <sprintf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <strcat@plt>
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   1040 <syscon_add_symbol@plt>
lea    (%r15,%rbx,1),%ecx
add    $0x1,%ecx
mov    %ebx,%edx
add    $0x1,%edx
mov    %edx,%ebx
cmp    $0x1,%ecx
jne    1170 <padcon_add_symbols+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
ret

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

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