#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 */
char *malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, unsigned long long const);
scalar_t__ strlen(char *);
char *make_assignment_name(size_t idx) {
  const unsigned long long int idx_llu = idx;
  char *arg = NULL;
  size_t numbers = 1;
  if (9 < idx) {
    numbers = 2;
  }
  arg = malloc(numbers + strlen("arg") + 1);
  if (NULL == arg) {
    return NULL;
  }
  sprintf(arg, "arg%llu", idx_llu);
  return arg;
}


x86 assembly (clang, -O0):
<make_assignment_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
mov    $0x9,%eax
cmp    -0x10(%rbp),%rax
jae    116b <make_assignment_name+0x3b>
movq   $0x2,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xe86(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    11ac <make_assignment_name+0x7c>
movq   $0x0,-0x8(%rbp)
jmp    11c8 <make_assignment_name+0x98>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe49(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_assignment_name>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmp    $0xa,%rdi
mov    $0x5,%edi
sbb    $0xffffffffffffffff,%rdi
call   1030 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1153 <make_assignment_name+0x33>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1040 <sprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str.1 = [8 x i8] c"arg%llu\00"
define noalias i8* @make_assignment_name(i64 %0) {
%2 = icmp ugt i64 %0, 9
%3 = select i1 %2, i64 6, i64 5
%4 = tail call i8* @malloc(i64 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %0)
br label %8
8: ; preds = %1, %6
ret i8* %4
}