#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*/ exit(int);
char *malloc(unsigned int);
char *arg_gen(unsigned int length, char insert) {
  int iter;
  char val;
  char *buf;
  buf = malloc(length + 1);
  if (!buf)
    exit(1);
  for (iter = 0; iter < length; iter++) {
    if (insert && iter % 2) {
      buf[iter] = insert;
    } else {
      val = iter % 0x10;
      buf[iter] = (val > 9 ? 55 + val : 48 + val);
    }
  }
  buf[length] = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<arg_gen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1155 <arg_gen+0x35>
mov    $0x1,%edi
call   1040 <exit@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11f5 <arg_gen+0xd5>
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
je     119c <arg_gen+0x7c>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     119c <arg_gen+0x7c>
mov    -0x5(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11e2 <arg_gen+0xc2>
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0x9,%eax
jle    11c8 <arg_gen+0xa8>
movsbl -0xd(%rbp),%eax
add    $0x37,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d2 <arg_gen+0xb2>
movsbl -0xd(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11e7 <arg_gen+0xc7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115c <arg_gen+0x3c>
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_gen>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
lea    0x1(%rbx),%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     14f5 <arg_gen+0x3d5>
test   %ebx,%ebx
je     114d <arg_gen+0x2d>
mov    %ebx,%ecx
cmp    $0x10,%ebx
jae    1154 <arg_gen+0x34>
xor    %edx,%edx
jmp    14e5 <arg_gen+0x3c5>
xor    %ecx,%ecx
jmp    14b2 <arg_gen+0x392>
mov    %ecx,%edx
and    $0xfffffff0,%edx
movzbl %bpl,%esi
movd   %esi,%xmm0
punpcklbw %xmm0,%xmm0
pshuflw $0x0,%xmm0,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa %xmm0,(%rsp)
lea    -0x10(%rdx),%rsi
mov    %rsi,%rbx
shr    $0x4,%rbx
add    $0x1,%rbx
test   %rsi,%rsi
je     1348 <arg_gen+0x228>
mov    %rbx,%rdi
and    $0xfffffffffffffffe,%rdi
movdqa 0xe65(%rip),%xmm7
movdqa 0xe6c(%rip),%xmm9
movdqa 0xe73(%rip),%xmm11
movdqa 0xe7b(%rip),%xmm5
xor    %esi,%esi
movdqa 0xea0(%rip),%xmm10
movdqa 0xea7(%rip),%xmm12
movdqa 0xeae(%rip),%xmm13
movdqa 0xeb5(%rip),%xmm14
movdqa 0xebc(%rip),%xmm15
jmp    12fc <arg_gen+0x1dc>
nopl   0x0(%rax)
psllw  $0x7,%xmm0
pand   0xe53(%rip),%xmm0
pcmpgtb %xmm0,%xmm6
movdqa %xmm9,%xmm8
pand   %xmm10,%xmm8
movdqa %xmm7,%xmm3
pand   %xmm10,%xmm3
movdqa %xmm5,%xmm2
pand   %xmm10,%xmm2
movdqa %xmm8,%xmm0
pcmpgtd %xmm12,%xmm0
movdqa %xmm8,%xmm4
paddd  %xmm13,%xmm4
por    %xmm14,%xmm8
pand   %xmm0,%xmm4
pandn  %xmm8,%xmm0
movdqa %xmm3,%xmm1
pcmpgtd %xmm12,%xmm1
por    %xmm4,%xmm0
movdqa %xmm3,%xmm4
paddd  %xmm13,%xmm4
por    %xmm14,%xmm3
pand   %xmm1,%xmm4
pandn  %xmm3,%xmm1
movdqa %xmm11,%xmm3
pand   %xmm10,%xmm3
por    %xmm4,%xmm1
movdqa %xmm2,%xmm4
pcmpgtd %xmm12,%xmm4
packuswb %xmm1,%xmm0
movdqa %xmm2,%xmm1
paddd  %xmm13,%xmm1
por    %xmm14,%xmm2
pand   %xmm4,%xmm1
pandn  %xmm2,%xmm4
movdqa %xmm3,%xmm2
pcmpgtd %xmm12,%xmm2
por    %xmm1,%xmm4
movdqa %xmm3,%xmm1
paddd  %xmm13,%xmm1
por    %xmm14,%xmm3
pand   %xmm2,%xmm1
pandn  %xmm3,%xmm2
por    %xmm1,%xmm2
packuswb %xmm2,%xmm4
packuswb %xmm0,%xmm4
movdqa (%rsp),%xmm0
pand   %xmm6,%xmm0
pandn  %xmm4,%xmm6
por    %xmm0,%xmm6
movdqu %xmm6,(%rax,%rsi,1)
movdqu %xmm6,0x10(%rax,%rsi,1)
add    $0x20,%rsi
paddd  %xmm15,%xmm5
paddd  %xmm15,%xmm11
paddd  %xmm15,%xmm9
paddd  %xmm15,%xmm7
add    $0xfffffffffffffffe,%rdi
je     136c <arg_gen+0x24c>
pxor   %xmm6,%xmm6
pxor   %xmm0,%xmm0
test   %bpl,%bpl
je     11f0 <arg_gen+0xd0>
movdqa %xmm5,%xmm0
movdqa 0xd27(%rip),%xmm1
pand   %xmm1,%xmm0
movdqa %xmm11,%xmm2
pand   %xmm1,%xmm2
packuswb %xmm2,%xmm0
movdqa %xmm9,%xmm2
pand   %xmm1,%xmm2
movdqa %xmm7,%xmm3
pand   %xmm1,%xmm3
packuswb %xmm3,%xmm2
packuswb %xmm2,%xmm0
jmp    11f0 <arg_gen+0xd0>
movdqa 0xcb0(%rip),%xmm7
movdqa 0xcb7(%rip),%xmm9
movdqa 0xcbe(%rip),%xmm11
movdqa 0xcc6(%rip),%xmm5
xor    %esi,%esi
test   $0x1,%bl
je     14ad <arg_gen+0x38d>
pxor   %xmm10,%xmm10
pxor   %xmm0,%xmm0
test   %bpl,%bpl
je     13b5 <arg_gen+0x295>
movdqa 0xcb5(%rip),%xmm1
movdqa %xmm5,%xmm0
pand   %xmm1,%xmm0
movdqa %xmm11,%xmm2
pand   %xmm1,%xmm2
packuswb %xmm2,%xmm0
movdqa %xmm9,%xmm2
pand   %xmm1,%xmm2
pand   %xmm7,%xmm1
packuswb %xmm1,%xmm2
packuswb %xmm2,%xmm0
psllw  $0x7,%xmm0
pand   0xc8e(%rip),%xmm0
pcmpgtb %xmm0,%xmm10
movdqa 0xc91(%rip),%xmm0
pand   %xmm0,%xmm9
pand   %xmm0,%xmm7
pand   %xmm0,%xmm5
pand   %xmm0,%xmm11
movdqa 0xc87(%rip),%xmm0
movdqa %xmm11,%xmm6
pcmpgtd %xmm0,%xmm6
movdqa %xmm5,%xmm2
pcmpgtd %xmm0,%xmm2
movdqa %xmm7,%xmm4
pcmpgtd %xmm0,%xmm4
movdqa %xmm9,%xmm3
pcmpgtd %xmm0,%xmm3
movdqa 0xc6d(%rip),%xmm1
movdqa %xmm11,%xmm8
paddd  %xmm1,%xmm8
movdqa %xmm5,%xmm12
paddd  %xmm1,%xmm12
movdqa %xmm7,%xmm0
paddd  %xmm1,%xmm0
paddd  %xmm9,%xmm1
movdqa 0xc53(%rip),%xmm13
por    %xmm13,%xmm11
por    %xmm13,%xmm5
por    %xmm13,%xmm7
por    %xmm13,%xmm9
pand   %xmm3,%xmm1
pandn  %xmm9,%xmm3
por    %xmm1,%xmm3
pand   %xmm4,%xmm0
pandn  %xmm7,%xmm4
por    %xmm0,%xmm4
packuswb %xmm4,%xmm3
pand   %xmm2,%xmm12
pandn  %xmm5,%xmm2
por    %xmm12,%xmm2
pand   %xmm6,%xmm8
pandn  %xmm11,%xmm6
por    %xmm8,%xmm6
packuswb %xmm6,%xmm2
packuswb %xmm3,%xmm2
movdqa (%rsp),%xmm0
pand   %xmm10,%xmm0
pandn  %xmm2,%xmm10
por    %xmm0,%xmm10
movdqu %xmm10,(%rax,%rsi,1)
cmp    %rcx,%rdx
jne    14e5 <arg_gen+0x3c5>
movb   $0x0,(%rax,%rcx,1)
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
nopl   (%rax)
mov    %edx,%esi
and    $0xf,%esi
lea    0x30(%rsi),%edi
lea    0x37(%rsi),%ebx
cmp    $0xa,%esi
movzbl %bl,%ebx
movzbl %dil,%esi
cmovae %ebx,%esi
mov    %sil,(%rax,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%rcx
je     14b2 <arg_gen+0x392>
test   %bpl,%bpl
je     14c0 <arg_gen+0x3a0>
mov    %edx,%edi
mov    %ebp,%esi
and    $0x1,%edi
jne    14d8 <arg_gen+0x3b8>
jmp    14c0 <arg_gen+0x3a0>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
define i8* @arg_gen(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8*
store i32 %0, i32* %3
store i8 %1, i8* %4
%8 = load i32, i32* %3
%9 = add i32 %8, 1
%10 = call i8* @malloc(i32 %9)
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %2
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
store i32 0, i32* %5
br label %16
16: ; preds = %57, %15
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = icmp ult i32 %17, %18
br i1 %19, label %20, label %60
20: ; preds = %16
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load i32, i32* %5
%26 = srem i32 %25, 2
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = load i8, i8* %4
%30 = load i8*, i8** %7
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 %29, i8* %33
br label %56
34: ; preds = %24, %20
%35 = load i32, i32* %5
%36 = srem i32 %35, 16
%37 = trunc i32 %36 to i8
store i8 %37, i8* %6
%38 = load i8, i8* %6
%39 = sext i8 %38 to i32
%40 = icmp sgt i32 %39, 9
br i1 %40, label %41, label %45
41: ; preds = %34
%42 = load i8, i8* %6
%43 = sext i8 %42 to i32
%44 = add nsw i32 55, %43
br label %49
45: ; preds = %34
%46 = load i8, i8* %6
%47 = sext i8 %46 to i32
%48 = add nsw i32 48, %47
br label %49
49: ; preds = %45, %41
%50 = phi i32 [ %44, %41 ], [ %48, %45 ]
%51 = trunc i32 %50 to i8
%52 = load i8*, i8** %7
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 %51, i8* %55
br label %56
56: ; preds = %49, %28
br label %57
57: ; preds = %56
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %16
60: ; preds = %16
%61 = load i8*, i8** %7
%62 = load i32, i32* %3
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
store i8 0, i8* %64
%65 = load i8*, i8** %7
ret i8* %65
}

LLVM IR (-O2):
define noalias i8* @arg_gen(i32 %0, i8 signext %1) {
%3 = add i32 %0, 1
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %74, label %6
6: ; preds = %2
%7 = icmp eq i32 %0, 0
br i1 %7, label %94, label %8
8: ; preds = %6
%9 = icmp eq i8 %1, 0
%10 = zext i32 %0 to i64
%11 = icmp ult i32 %0, 16
br i1 %11, label %72, label %12
12: ; preds = %8
%13 = and i64 %10, 4294967280
%14 = insertelement <16 x i8> poison, i8 %1, i64 0
%15 = shufflevector <16 x i8> %14, <16 x i8> poison, <16 x i32> zeroinitializer
%16 = add nsw i64 %13, -16
%17 = lshr exact i64 %16, 4
%18 = add nuw nsw i64 %17, 1
%19 = and i64 %18, 1
%20 = icmp eq i64 %16, 0
br i1 %20, label %54, label %21
21: ; preds = %12
%22 = and i64 %18, 2305843009213693950
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %50, %23 ]
%25 = phi <16 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>, %21 ], [ %51, %23 ]
%26 = phi i64 [ 0, %21 ], [ %52, %23 ]
%27 = trunc <16 x i32> %25 to <16 x i1>
%28 = select i1 %9, <16 x i1> zeroinitializer, <16 x i1> %27
%29 = and <16 x i32> %25, <i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15>
%30 = icmp ugt <16 x i32> %29, <i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9>
%31 = add nuw nsw <16 x i32> %29, <i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55>
%32 = or <16 x i32> %29, <i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48>
%33 = select <16 x i1> %30, <16 x i32> %31, <16 x i32> %32
%34 = trunc <16 x i32> %33 to <16 x i8>
%35 = select <16 x i1> %28, <16 x i8> %15, <16 x i8> %34
%36 = getelementptr inbounds i8, i8* %4, i64 %24
%37 = bitcast i8* %36 to <16 x i8>*
store <16 x i8> %35, <16 x i8>* %37
%38 = or i64 %24, 16
%39 = trunc <16 x i32> %25 to <16 x i1>
%40 = select i1 %9, <16 x i1> zeroinitializer, <16 x i1> %39
%41 = and <16 x i32> %25, <i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15>
%42 = icmp ugt <16 x i32> %41, <i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9>
%43 = add nuw nsw <16 x i32> %41, <i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55>
%44 = or <16 x i32> %41, <i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48>
%45 = select <16 x i1> %42, <16 x i32> %43, <16 x i32> %44
%46 = trunc <16 x i32> %45 to <16 x i8>
%47 = select <16 x i1> %40, <16 x i8> %15, <16 x i8> %46
%48 = getelementptr inbounds i8, i8* %4, i64 %38
%49 = bitcast i8* %48 to <16 x i8>*
store <16 x i8> %47, <16 x i8>* %49
%50 = add nuw i64 %24, 32
%51 = add <16 x i32> %25, <i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32>
%52 = add i64 %26, 2
%53 = icmp eq i64 %52, %22
br i1 %53, label %54, label %23
54: ; preds = %23, %12
%55 = phi i64 [ 0, %12 ], [ %50, %23 ]
%56 = phi <16 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>, %12 ], [ %51, %23 ]
%57 = icmp eq i64 %19, 0
br i1 %57, label %70, label %58
58: ; preds = %54
%59 = trunc <16 x i32> %56 to <16 x i1>
%60 = select i1 %9, <16 x i1> zeroinitializer, <16 x i1> %59
%61 = and <16 x i32> %56, <i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15>
%62 = icmp ugt <16 x i32> %61, <i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9>
%63 = add nuw nsw <16 x i32> %61, <i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55, i32 55>
%64 = or <16 x i32> %61, <i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48>
%65 = select <16 x i1> %62, <16 x i32> %63, <16 x i32> %64
%66 = trunc <16 x i32> %65 to <16 x i8>
%67 = select <16 x i1> %60, <16 x i8> %15, <16 x i8> %66
%68 = getelementptr inbounds i8, i8* %4, i64 %55
%69 = bitcast i8* %68 to <16 x i8>*
store <16 x i8> %67, <16 x i8>* %69
br label %70
70: ; preds = %54, %58
%71 = icmp eq i64 %13, %10
br i1 %71, label %94, label %72
72: ; preds = %8, %70
%73 = phi i64 [ 0, %8 ], [ %13, %70 ]
br label %76
74: ; preds = %2
%75 = tail call i32 @exit(i32 1)
unreachable
76: ; preds = %72, %89
%77 = phi i64 [ %92, %89 ], [ %73, %72 ]
%78 = trunc i64 %77 to i32
%79 = and i32 %78, 1
%80 = icmp eq i32 %79, 0
%81 = select i1 %9, i1 true, i1 %80
br i1 %81, label %82, label %89
82: ; preds = %76
%83 = and i32 %78, 15
%84 = icmp ugt i32 %83, 9
%85 = add nuw nsw i32 %83, 55
%86 = or i32 %83, 48
%87 = select i1 %84, i32 %85, i32 %86
%88 = trunc i32 %87 to i8
br label %89
89: ; preds = %76, %82
%90 = phi i8 [ %88, %82 ], [ %1, %76 ]
%91 = getelementptr inbounds i8, i8* %4, i64 %77
store i8 %90, i8* %91
%92 = add nuw nsw i64 %77, 1
%93 = icmp eq i64 %92, %10
br i1 %93, label %94, label %76
94: ; preds = %89, %70, %6
%95 = phi i64 [ 0, %6 ], [ %10, %70 ], [ %10, %89 ]
%96 = getelementptr inbounds i8, i8* %4, i64 %95
store i8 0, i8* %96
ret i8* %4
}