#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*/ fprintf(int /*<<< orphan*/, char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, unsigned long long const, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char const *);
char *make_mock_arg_name(size_t idx, int function_pointer,
                         const char *function_pointer_args, int asterisks,
                         int array) {
  char *arg = NULL;
  size_t numbers = 1;
  size_t fpchars = 0;
  const unsigned long long int idx_llu = idx;
  if (9 < idx) {
    numbers = 2;
  }
  if (1 == function_pointer) {
    fpchars = 3;
    fpchars += strlen(function_pointer_args);
  }
  arg = malloc(numbers + fpchars + asterisks + strlen("arg") + 1 + array);
  if (1 == function_pointer) {
    sprintf(arg, "(*arg%llu)%s", idx_llu, function_pointer_args);
  } else {
    if (0 == array) {
      if (0 == asterisks) {
        sprintf(arg, "arg%llu", idx_llu);
      } else if (1 == asterisks) {
        sprintf(arg, "*arg%llu", idx_llu);
      } else {
        sprintf(arg, "**arg%llu", idx_llu);
      }
    } else {
      if (0 == asterisks) {
        sprintf(arg, "*arg%llu", idx_llu);
      } else if (1 == asterisks) {
        sprintf(arg, "**arg%llu", idx_llu);
      } else {
        fprintf(stderr, "ERROR: Too many asterisks for an array ref\n");
      }
    }
  }
  return arg;
}


x86 assembly (clang, -O0):
<make_mock_arg_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x1,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x9,%eax
cmp    -0x8(%rbp),%rax
jae    1191 <make_mock_arg_name+0x51>
movq   $0x2,-0x30(%rbp)
mov    $0x1,%eax
cmp    -0xc(%rbp),%eax
jne    11b8 <make_mock_arg_name+0x78>
movq   $0x3,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
add    -0x38(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
lea    0xe2e(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x48(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x1,%eax
cmp    -0xc(%rbp),%eax
jne    121f <make_mock_arg_name+0xdf>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    130c <make_mock_arg_name+0x1cc>
xor    %eax,%eax
cmp    -0x20(%rbp),%eax
jne    1299 <make_mock_arg_name+0x159>
xor    %eax,%eax
cmp    -0x1c(%rbp),%eax
jne    1250 <make_mock_arg_name+0x110>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    1294 <make_mock_arg_name+0x154>
mov    $0x1,%eax
cmp    -0x1c(%rbp),%eax
jne    1279 <make_mock_arg_name+0x139>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    128f <make_mock_arg_name+0x14f>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xd89(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    1294 <make_mock_arg_name+0x154>
jmp    1307 <make_mock_arg_name+0x1c7>
xor    %eax,%eax
cmp    -0x1c(%rbp),%eax
jne    12bf <make_mock_arg_name+0x17f>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xd5f(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    1302 <make_mock_arg_name+0x1c2>
mov    $0x1,%eax
cmp    -0x1c(%rbp),%eax
jne    12e8 <make_mock_arg_name+0x1a8>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xd35(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    12fd <make_mock_arg_name+0x1bd>
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
lea    0xd23(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1302 <make_mock_arg_name+0x1c2>
jmp    1307 <make_mock_arg_name+0x1c7>
jmp    130c <make_mock_arg_name+0x1cc>
mov    -0x28(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_mock_arg_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %ecx,%r13d
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rdi,%r15
cmp    $0x1,%esi
jne    116c <make_mock_arg_name+0x2c>
mov    %r12,%rdi
call   1030 <strlen@plt>
add    $0x3,%rax
jmp    116e <make_mock_arg_name+0x2e>
xor    %eax,%eax
cmp    $0xa,%r15
movslq %r13d,%rcx
movslq %ebx,%rdx
sbb    $0xffffffffffffffff,%rcx
add    %rdx,%rcx
lea    (%rax,%rcx,1),%rdi
add    $0x5,%rdi
call   1050 <malloc@plt>
mov    %rax,%r14
cmp    $0x1,%ebp
jne    11ad <make_mock_arg_name+0x6d>
lea    0xe65(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1060 <sprintf@plt>
jmp    1204 <make_mock_arg_name+0xc4>
test   %ebx,%ebx
je     11d3 <make_mock_arg_name+0x93>
cmp    $0x1,%r13d
je     11f0 <make_mock_arg_name+0xb0>
test   %r13d,%r13d
je     11e7 <make_mock_arg_name+0xa7>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1204 <make_mock_arg_name+0xc4>
cmp    $0x1,%r13d
je     11e7 <make_mock_arg_name+0xa7>
test   %r13d,%r13d
jne    11f0 <make_mock_arg_name+0xb0>
lea    0xe2a(%rip),%rsi
jmp    11f7 <make_mock_arg_name+0xb7>
lea    0xe20(%rip),%rsi
jmp    11f7 <make_mock_arg_name+0xb7>
lea    0xe16(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"arg\00"
@.str.1 = [13 x i8] c"(*arg%llu)%s\00"
@.str.2 = [8 x i8] c"arg%llu\00"
@.str.3 = [9 x i8] c"*arg%llu\00"
@.str.4 = [10 x i8] c"**arg%llu\00"
@stderr = global i32 0
@.str.5 = [44 x i8] c"ERROR: Too many asterisks for an array ref\0A\00"
define i8* @make_mock_arg_name(i64 %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
store i64 %0, i64* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i8* null, i8** %11
store i64 1, i64* %12
store i64 0, i64* %13
%15 = load i64, i64* %6
store i64 %15, i64* %14
%16 = load i64, i64* %6
%17 = icmp ult i64 9, %16
br i1 %17, label %18, label %19
18: ; preds = %5
store i64 2, i64* %12
br label %19
19: ; preds = %18, %5
%20 = load i32, i32* %7
%21 = icmp eq i32 1, %20
br i1 %21, label %22, label %27
22: ; preds = %19
store i64 3, i64* %13
%23 = load i8*, i8** %8
%24 = call i64 @strlen(i8* %23)
%25 = load i64, i64* %13
%26 = add i64 %25, %24
store i64 %26, i64* %13
br label %27
27: ; preds = %22, %19
%28 = load i64, i64* %12
%29 = load i64, i64* %13
%30 = add i64 %28, %29
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = add i64 %30, %32
%34 = call i64 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%35 = add i64 %33, %34
%36 = add i64 %35, 1
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = add i64 %36, %38
%40 = call i8* @malloc(i64 %39)
store i8* %40, i8** %11
%41 = load i32, i32* %7
%42 = icmp eq i32 1, %41
br i1 %42, label %43, label %48
43: ; preds = %27
%44 = load i8*, i8** %11
%45 = load i64, i64* %14
%46 = load i8*, i8** %8
%47 = call i32 (i8*, i8*, i64, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %45, i8* %46)
br label %91
48: ; preds = %27
%49 = load i32, i32* %10
%50 = icmp eq i32 0, %49
br i1 %50, label %51, label %71
51: ; preds = %48
%52 = load i32, i32* %9
%53 = icmp eq i32 0, %52
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load i8*, i8** %11
%56 = load i64, i64* %14
%57 = call i32 (i8*, i8*, i64, ...) @sprintf(i8* %55, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %56)
br label %70
58: ; preds = %51
%59 = load i32, i32* %9
%60 = icmp eq i32 1, %59
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = load i8*, i8** %11
%63 = load i64, i64* %14
%64 = call i32 (i8*, i8*, i64, ...) @sprintf(i8* %62, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 %63)
br label %69
65: ; preds = %58
%66 = load i8*, i8** %11
%67 = load i64, i64* %14
%68 = call i32 (i8*, i8*, i64, ...) @sprintf(i8* %66, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i64 %67)
br label %69
69: ; preds = %65, %61
br label %70
70: ; preds = %69, %54
br label %90
71: ; preds = %48
%72 = load i32, i32* %9
%73 = icmp eq i32 0, %72
br i1 %73, label %74, label %78
74: ; preds = %71
%75 = load i8*, i8** %11
%76 = load i64, i64* %14
%77 = call i32 (i8*, i8*, i64, ...) @sprintf(i8* %75, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 %76)
br label %89
78: ; preds = %71
%79 = load i32, i32* %9
%80 = icmp eq i32 1, %79
br i1 %80, label %81, label %85
81: ; preds = %78
%82 = load i8*, i8** %11
%83 = load i64, i64* %14
%84 = call i32 (i8*, i8*, i64, ...) @sprintf(i8* %82, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i64 %83)
br label %88
85: ; preds = %78
%86 = load i32, i32* @stderr
%87 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
br label %88
88: ; preds = %85, %81
br label %89
89: ; preds = %88, %74
br label %90
90: ; preds = %89, %70
br label %91
91: ; preds = %90, %43
%92 = load i8*, i8** %11
ret i8* %92
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"(*arg%llu)%s\00"
@.str.2 = [8 x i8] c"arg%llu\00"
@.str.3 = [9 x i8] c"*arg%llu\00"
@.str.4 = [10 x i8] c"**arg%llu\00"
@stderr = global i32 0
@.str.5 = [44 x i8] c"ERROR: Too many asterisks for an array ref\0A\00"
define noalias i8* @make_mock_arg_name(i64 %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = icmp ugt i64 %0, 9
%7 = icmp eq i32 %1, 1
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%10 = add i64 %9, 3
br label %11
11: ; preds = %8, %5
%12 = phi i64 [ %10, %8 ], [ 0, %5 ]
%13 = sext i32 %3 to i64
%14 = sext i32 %4 to i64
%15 = select i1 %6, i64 6, i64 5
%16 = add nsw i64 %15, %13
%17 = add nsw i64 %16, %14
%18 = add i64 %17, %12
%19 = tail call i8* @malloc(i64 %18)
br i1 %7, label %20, label %22
20: ; preds = %11
%21 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %0, i8* %2)
br label %39
22: ; preds = %11
%23 = icmp eq i32 %4, 0
br i1 %23, label %24, label %31
24: ; preds = %22
switch i32 %3, label %29 [
i32 0, label %25
i32 1, label %27
]
25: ; preds = %24
%26 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %0)
br label %39
27: ; preds = %24
%28 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 %0)
br label %39
29: ; preds = %24
%30 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i64 %0)
br label %39
31: ; preds = %22
switch i32 %3, label %36 [
i32 0, label %32
i32 1, label %34
]
32: ; preds = %31
%33 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 %0)
br label %39
34: ; preds = %31
%35 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i64 %0)
br label %39
36: ; preds = %31
%37 = load i32, i32* @stderr
%38 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
br label %39
39: ; preds = %27, %29, %25, %34, %36, %32, %20
ret i8* %19
}