#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*/ add_output(char *);
int atoi(char *);
int get_factor(int);
int /*<<< orphan*/ set_factor(int, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
void gtp_hg_factors(int gtp_argc, char gtp_argv[][20]) {
  int k;
  int factor;
  char output[(4 * 9) + 1];
  char temp[4];
  output[0] = '\0';
  temp[0] = '\0';
  if (gtp_argc == 0) {
    for (k = 0; k < 9; k++) {
      snprintf(temp, 4, "%d", get_factor(k));
      strcat(output, temp);
      strcat(output, " ");
    }
    add_output(output);
    return;
  }
  for (k = 0; k < gtp_argc; k++) {
    factor = atoi(gtp_argv[k]);
    set_factor(k, factor);
  }
  return;
}


x86 assembly (clang, -O0):
<gtp_hg_factors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x40(%rbp)
movb   $0x0,-0x44(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11f2 <gtp_hg_factors+0x92>
movl   $0x0,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jge    11e4 <gtp_hg_factors+0x84>
lea    -0x44(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <get_factor@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%ecx
mov    $0x4,%esi
lea    0xe4c(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x44(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x40(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <gtp_hg_factors+0x28>
lea    -0x40(%rbp),%rdi
call   1080 <add_output@plt>
jmp    123a <gtp_hg_factors+0xda>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1235 <gtp_hg_factors+0xd5>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <set_factor@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f9 <gtp_hg_factors+0x99>
jmp    123a <gtp_hg_factors+0xda>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gtp_hg_factors>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movb   $0x0,0x10(%rsp)
movb   $0x0,0xc(%rsp)
test   %edi,%edi
je     11b3 <gtp_hg_factors+0x53>
jle    1392 <gtp_hg_factors+0x232>
mov    %rsi,%r14
mov    %edi,%r15d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <atoi@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <set_factor@plt>
add    $0x1,%rbx
add    $0x14,%r14
cmp    %rbx,%r15
jne    1190 <gtp_hg_factors+0x30>
jmp    1392 <gtp_hg_factors+0x232>
xor    %edi,%edi
call   1040 <get_factor@plt>
lea    0xe3f(%rip),%r15
lea    0xc(%rsp),%r14
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1030 <snprintf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
lea    0xe14(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    $0x1,%edi
call   1040 <get_factor@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    $0x2,%edi
call   1040 <get_factor@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    $0x3,%edi
call   1040 <get_factor@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    $0x4,%edi
call   1040 <get_factor@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    $0x5,%edi
call   1040 <get_factor@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    $0x6,%edi
call   1040 <get_factor@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    $0x7,%edi
call   1040 <get_factor@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    $0x8,%edi
call   1040 <get_factor@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1080 <add_output@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c" \00"
define void @gtp_hg_factors(i32 %0, [20 x i8]* %1) {
%3 = alloca i32
%4 = alloca [20 x i8]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [37 x i8]
%8 = alloca [4 x i8]
store i32 %0, i32* %3
store [20 x i8]* %1, [20 x i8]** %4
%9 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 0
store i8 0, i8* %9
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
store i8 0, i8* %10
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %2
store i32 0, i32* %5
br label %14
14: ; preds = %27, %13
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 9
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%19 = load i32, i32* %5
%20 = call i32 @get_factor(i32 %19)
%21 = call i32 @snprintf(i8* %18, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 0
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%24 = call i32 @strcat(i8* %22, i8* %23)
%25 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 0
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %17
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %14
30: ; preds = %14
%31 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 0
%32 = call i32 @add_output(i8* %31)
br label %52
33: ; preds = %2
store i32 0, i32* %5
br label %34
34: ; preds = %48, %33
%35 = load i32, i32* %5
%36 = load i32, i32* %3
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %51
38: ; preds = %34
%39 = load [20 x i8]*, [20 x i8]** %4
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %39, i64 %41
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %42, i64 0, i64 0
%44 = call i32 @atoi(i8* %43)
store i32 %44, i32* %6
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = call i32 @set_factor(i32 %45, i32 %46)
br label %48
48: ; preds = %38
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %34
51: ; preds = %34
br label %52
52: ; preds = %51, %30
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c" \00"
define void @gtp_hg_factors(i32 %0, [20 x i8]* nocapture %1) {
%3 = alloca [37 x i8]
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [37 x i8], [37 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
store i8 0, i8* %5
store i8 0, i8* %6
%7 = icmp eq i32 %0, 0
br i1 %7, label %8, label %46
8: ; preds = %2
%9 = call i32 @get_factor(i32 0)
%10 = call i32 @snprintf(i8* %6, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @strcat(i8* %5, i8* %6)
%12 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @get_factor(i32 1)
%14 = call i32 @snprintf(i8* %6, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @strcat(i8* %5, i8* %6)
%16 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @get_factor(i32 2)
%18 = call i32 @snprintf(i8* %6, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 @strcat(i8* %5, i8* %6)
%20 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @get_factor(i32 3)
%22 = call i32 @snprintf(i8* %6, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = call i32 @strcat(i8* %5, i8* %6)
%24 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @get_factor(i32 4)
%26 = call i32 @snprintf(i8* %6, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = call i32 @strcat(i8* %5, i8* %6)
%28 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @get_factor(i32 5)
%30 = call i32 @snprintf(i8* %6, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = call i32 @strcat(i8* %5, i8* %6)
%32 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @get_factor(i32 6)
%34 = call i32 @snprintf(i8* %6, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = call i32 @strcat(i8* %5, i8* %6)
%36 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @get_factor(i32 7)
%38 = call i32 @snprintf(i8* %6, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = call i32 @strcat(i8* %5, i8* %6)
%40 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @get_factor(i32 8)
%42 = call i32 @snprintf(i8* %6, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = call i32 @strcat(i8* %5, i8* %6)
%44 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 @add_output(i8* %5)
br label %58
46: ; preds = %2
%47 = icmp sgt i32 %0, 0
br i1 %47, label %48, label %58
48: ; preds = %46
%49 = zext i32 %0 to i64
br label %50
50: ; preds = %48, %50
%51 = phi i64 [ 0, %48 ], [ %56, %50 ]
%52 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 %51, i64 0
%53 = tail call i32 @atoi(i8* %52)
%54 = trunc i64 %51 to i32
%55 = tail call i32 @set_factor(i32 %54, i32 %53)
%56 = add nuw nsw i64 %51, 1
%57 = icmp eq i64 %56, %49
br i1 %57, label %58, label %50
58: ; preds = %50, %46, %8
ret void
}