#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ KAPI_save_as_header_uint(int /*<<< orphan*/ *,
                                            unsigned long);
int /*<<< orphan*/ KAPI_save_as_header_uint_list(int /*<<< orphan*/ *,
                                                 unsigned long);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int strlen(char *);
void KAPI_save_as_header_uint_array(FILE *fp, unsigned long *pint,
                                    int number_of_elements) {
  int i;
  FILE *fpTmp = fp;
  fwrite("{", sizeof(char), 1, fpTmp);
  for (i = 0; i < number_of_elements - 1; i++)
    KAPI_save_as_header_uint_list(fp, pint[i]);
  KAPI_save_as_header_uint(fp, pint[i]);
  fwrite("}\n", sizeof(char), strlen("}\n"), fpTmp);
}


x86 assembly (clang, -O0):
<KAPI_save_as_header_uint_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
lea    0xe9a(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <fwrite@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ad <KAPI_save_as_header_uint_array+0x6d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <KAPI_save_as_header_uint_list@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1179 <KAPI_save_as_header_uint_array+0x39>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <KAPI_save_as_header_uint@plt>
lea    0xe39(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
lea    0xe27(%rip),%rdi
mov    $0x1,%esi
call   1060 <fwrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KAPI_save_as_header_uint_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0x7b,%edi
mov    %r14,%rsi
call   1060 <fputc@plt>
cmp    $0x2,%ebp
jl     1197 <KAPI_save_as_header_uint_array+0x47>
add    $0xffffffff,%ebp
mov    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <KAPI_save_as_header_uint_list@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <KAPI_save_as_header_uint_array+0x30>
jmp    1199 <KAPI_save_as_header_uint_array+0x49>
xor    %ebp,%ebp
mov    (%r15,%rbp,8),%rsi
mov    %r14,%rdi
call   1050 <KAPI_save_as_header_uint@plt>
lea    0xe54(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <fwrite@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"{\00"
@.str.1 = [3 x i8] c"}\0A\00"
define void @KAPI_save_as_header_uint_array(i32* %0, i64* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32* %0, i32** %4
store i64* %1, i64** %5
store i32 %2, i32* %6
%9 = load i32*, i32** %4
store i32* %9, i32** %8
%10 = load i32*, i32** %8
%11 = call i32 @fwrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1, i32 1, i32* %10)
store i32 0, i32* %7
br label %12
12: ; preds = %25, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = sub nsw i32 %14, 1
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %28
17: ; preds = %12
%18 = load i32*, i32** %4
%19 = load i64*, i64** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i64, i64* %19, i64 %21
%23 = load i64, i64* %22
%24 = call i32 @KAPI_save_as_header_uint_list(i32* %18, i64 %23)
br label %25
25: ; preds = %17
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %12
28: ; preds = %12
%29 = load i32*, i32** %4
%30 = load i64*, i64** %5
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i64, i64* %30, i64 %32
%34 = load i64, i64* %33
%35 = call i32 @KAPI_save_as_header_uint(i32* %29, i64 %34)
%36 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32*, i32** %8
%38 = call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %36, i32* %37)
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"}\0A\00"
define void @KAPI_save_as_header_uint_array(i32* %0, i64* nocapture %1, i32 %2) {
%4 = tail call i32 @fputc(i32 123, i32* %0)
%5 = add i32 %2, -1
%6 = icmp sgt i32 %2, 1
br i1 %6, label %7, label %18
7: ; preds = %3
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %14, %9 ]
%11 = getelementptr inbounds i64, i64* %1, i64 %10
%12 = load i64, i64* %11
%13 = tail call i32 @KAPI_save_as_header_uint_list(i32* %0, i64 %12)
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %8
br i1 %15, label %16, label %9
16: ; preds = %9
%17 = zext i32 %5 to i64
br label %18
18: ; preds = %3, %16
%19 = phi i64 [ %17, %16 ], [ 0, %3 ]
%20 = getelementptr inbounds i64, i64* %1, i64 %19
%21 = load i64, i64* %20
%22 = tail call i32 @KAPI_save_as_header_uint(i32* %0, i64 %21)
%23 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = tail call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %23, i32* %0)
ret void
}