#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 */
unsigned int ToHexDiv(unsigned int *);
int ToHexZeroCheck(unsigned int *);
void ToHex(unsigned w[], unsigned a[]) {
  int i;
  unsigned z[601];
  for (i = 0; i < 601; i++)
    z[i] = w[i];
  for (i = 0; i < 500; i++)
    a[i] = 0;
  i = 0;
  while (ToHexZeroCheck(z) == -1)
    a[i++] = ToHexDiv(z);
}


x86 assembly (clang, -O0):
<ToHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x980,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x259,-0x14(%rbp)
jge    116b <ToHex+0x4b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x980(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113a <ToHex+0x1a>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1f4,-0x14(%rbp)
jge    119c <ToHex+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1172 <ToHex+0x52>
movl   $0x0,-0x14(%rbp)
lea    -0x980(%rbp),%rdi
call   1030 <ToHexZeroCheck@plt>
cmp    $0xffffffff,%eax
jne    11e0 <ToHex+0xc0>
lea    -0x980(%rbp),%rdi
call   1040 <ToHexDiv@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11a3 <ToHex+0x83>
add    $0x980,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ToHex>:
push   %r14
push   %rbx
sub    $0x968,%rsp
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rsp,%r14
mov    $0x964,%edx
mov    %r14,%rdi
call   1050 <memcpy@plt>
mov    $0x7d0,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %r14,%rdi
call   1030 <ToHexZeroCheck@plt>
cmp    $0xffffffff,%eax
jne    119b <ToHex+0x5b>
mov    %rsp,%r14
nop
mov    %r14,%rdi
call   1060 <ToHexDiv@plt>
mov    %eax,(%rbx)
mov    %r14,%rdi
call   1030 <ToHexZeroCheck@plt>
add    $0x4,%rbx
cmp    $0xffffffff,%eax
je     1180 <ToHex+0x40>
add    $0x968,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @ToHex(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [601 x i32]
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %7
7: ; preds = %19, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 601
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = load i32*, i32** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [601 x i32], [601 x i32]* %6, i64 0, i64 %17
store i32 %15, i32* %18
br label %19
19: ; preds = %10
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %7
22: ; preds = %7
store i32 0, i32* %5
br label %23
23: ; preds = %31, %22
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 500
br i1 %25, label %26, label %34
26: ; preds = %23
%27 = load i32*, i32** %4
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
store i32 0, i32* %30
br label %31
31: ; preds = %26
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %23
34: ; preds = %23
store i32 0, i32* %5
br label %35
35: ; preds = %39, %34
%36 = getelementptr inbounds [601 x i32], [601 x i32]* %6, i64 0, i64 0
%37 = call i32 @ToHexZeroCheck(i32* %36)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %47
39: ; preds = %35
%40 = getelementptr inbounds [601 x i32], [601 x i32]* %6, i64 0, i64 0
%41 = call i32 @ToHexDiv(i32* %40)
%42 = load i32*, i32** %4
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i32, i32* %42, i64 %45
store i32 %41, i32* %46
br label %35
47: ; preds = %35
ret void
}

LLVM IR (-O2):
define void @ToHex(i32* nocapture %0, i32* nocapture writeonly %1) {
%3 = bitcast i32* %0 to i8*
%4 = bitcast i32* %1 to i8*
%5 = alloca [601 x i32]
%6 = bitcast [601 x i32]* %5 to i8*
%7 = getelementptr inbounds [601 x i32], [601 x i32]* %5, i64 0, i64 0
%8 = call i32 @ToHexZeroCheck(i32* %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %17
10: ; preds = %2, %10
%11 = phi i64 [ %13, %10 ], [ 0, %2 ]
%12 = call i32 @ToHexDiv(i32* %7)
%13 = add nuw i64 %11, 1
%14 = getelementptr inbounds i32, i32* %1, i64 %11
store i32 %12, i32* %14
%15 = call i32 @ToHexZeroCheck(i32* %7)
%16 = icmp eq i32 %15, -1
br i1 %16, label %10, label %17
17: ; preds = %10, %2
ret void
}