#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 */
char *BinString(char, char *, int);
int PutCharIntoArray(char *, int const, char);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ free(char *);
scalar_t__ isprint(char);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int const);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
void TestPutCharIntoArrayEx(const char *fname, const int line, char *srcArray,
                            const int sz, char msg, const int result,
                            char *resArray) {
  char *tmpArray = NULL;
  int rc = 0, idx = 0, cmpRes = 0;
  char buf[9];
  memset(buf, 0, sizeof(char) * 9);
  if (srcArray && (sz > 0)) {
    tmpArray = (char *)malloc(sizeof(char) * sz);
    memcpy(tmpArray, srcArray, sz);
  }
  printf(
      "\n[%s:%d]\nPut char (0x%02x) '%c' into array (0x%p) of size (%d): {\n",
      fname, line, msg, (isprint(msg) ? msg : '.'), srcArray, sz);
  if (tmpArray && (sz >= 1)) {
    for (idx = 0; idx < sz; ++idx) {
      printf("    [%2d]: (0x%02.2x) \"%s\"\n", idx,
             (((int)tmpArray[idx]) & 0x000000ff),
             BinString(tmpArray[idx], buf, 9));
    }
  }
  rc = PutCharIntoArray(tmpArray, sz, msg);
  printf("  }  == %d : expecting %d\n", rc, result);
  assert(rc == result);
  if (result == 0) {
    cmpRes = 1;
    printf("Compare resulting array to expected result\n");
    printf("       expected                       result\n");
    for (idx = 0; idx < sz; ++idx) {
      printf("  [%2d]: (0x%02.2x) \"%s\" == ", idx,
             (((int)resArray[idx]) & 0x000000ff),
             BinString(resArray[idx], buf, 9));
      printf("(0x%02.2x) \"%s\" : ", (((int)tmpArray[idx]) & 0x000000ff),
             BinString(tmpArray[idx], buf, 9));
      printf("%s\n", (tmpArray[idx] == resArray[idx] ? "true" : "false"));
      cmpRes = cmpRes && (tmpArray[idx] == resArray[idx]);
    }
    assert(cmpRes != 0);
  }
  if (tmpArray) {
    free(tmpArray);
    tmpArray = NULL;
  }
}


x86 assembly (clang, -O0):
<TestPutCharIntoArrayEx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %r8b,%al
mov    0x10(%rbp),%r8
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
mov    %r9d,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
lea    -0x45(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1060 <memset@plt>
cmpq   $0x0,-0x18(%rbp)
je     121c <TestPutCharIntoArrayEx+0x8c>
cmpl   $0x0,-0x1c(%rbp)
jle    121c <TestPutCharIntoArrayEx+0x8c>
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1080 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x50(%rbp)
movsbl -0x1d(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movsbl -0x1d(%rbp),%edi
call   10b0 <isprint@plt>
cmp    $0x0,%rax
je     1250 <TestPutCharIntoArrayEx+0xc0>
movsbl -0x1d(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    125d <TestPutCharIntoArrayEx+0xcd>
mov    $0x2e,%eax
mov    %eax,-0x5c(%rbp)
jmp    125d <TestPutCharIntoArrayEx+0xcd>
mov    -0x4c(%rbp),%ecx
mov    -0x50(%rbp),%edx
mov    -0x58(%rbp),%rsi
mov    -0x5c(%rbp),%r8d
mov    -0x18(%rbp),%r9
mov    -0x1c(%rbp),%eax
lea    0xd87(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x30(%rbp)
je     130b <TestPutCharIntoArrayEx+0x17b>
cmpl   $0x1,-0x1c(%rbp)
jl     130b <TestPutCharIntoArrayEx+0x17b>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1306 <TestPutCharIntoArrayEx+0x176>
mov    -0x38(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xff,%eax
mov    %eax,-0x60(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,1),%al
lea    -0x45(%rbp),%rsi
mov    $0x9,%edx
movsbl %al,%edi
call   1090 <BinString@plt>
mov    -0x64(%rbp),%esi
mov    -0x60(%rbp),%edx
mov    %rax,%rcx
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    129f <TestPutCharIntoArrayEx+0x10f>
jmp    130b <TestPutCharIntoArrayEx+0x17b>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
movsbl -0x1d(%rbp),%edx
call   1040 <PutCharIntoArray@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x0,-0x24(%rbp)
jne    14a9 <TestPutCharIntoArrayEx+0x319>
movl   $0x1,-0x3c(%rbp)
lea    0xd1d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1498 <TestPutCharIntoArrayEx+0x308>
mov    -0x38(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xff,%eax
mov    %eax,-0x70(%rbp)
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,1),%al
lea    -0x45(%rbp),%rsi
mov    $0x9,%edx
movsbl %al,%edi
call   1090 <BinString@plt>
mov    -0x74(%rbp),%esi
mov    -0x70(%rbp),%edx
mov    %rax,%rcx
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xff,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,1),%al
lea    -0x45(%rbp),%rsi
mov    $0x9,%edx
movsbl %al,%edi
call   1090 <BinString@plt>
mov    -0x6c(%rbp),%esi
mov    %rax,%rdx
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rdx
movsbl (%rax,%rdx,1),%edx
lea    0xcd8(%rip),%rsi
lea    0xccc(%rip),%rax
cmp    %edx,%ecx
cmove  %rax,%rsi
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x3c(%rbp)
mov    %al,-0x65(%rbp)
je     147f <TestPutCharIntoArrayEx+0x2ef>
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    0x10(%rbp),%rcx
movslq -0x38(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x65(%rbp)
mov    -0x65(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1379 <TestPutCharIntoArrayEx+0x1e9>
cmpl   $0x0,-0x3c(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpq   $0x0,-0x30(%rbp)
je     14c5 <TestPutCharIntoArrayEx+0x335>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestPutCharIntoArrayEx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,0x18(%rsp)
mov    %r8d,%r15d
mov    %ecx,%ebx
mov    %rdx,%r13
mov    %esi,0x8(%rsp)
mov    %rdi,%r12
lea    0x1f(%rsp),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0x9,%edx
call   1070 <memset@plt>
test   %r13,%r13
je     11f6 <TestPutCharIntoArrayEx+0x56>
test   %ebx,%ebx
jle    11f6 <TestPutCharIntoArrayEx+0x56>
mov    %ebx,%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1090 <memcpy@plt>
movsbl %r15b,%ebp
mov    %ebp,%edi
call   10c0 <isprint@plt>
test   %rax,%rax
mov    $0x2e,%r8d
cmovne %ebp,%r8d
mov    %ebx,(%rsp)
lea    0xde8(%rip),%rdi
mov    %r12,%rsi
mov    0x8(%rsp),%edx
mov    %ebp,0x14(%rsp)
mov    %ebp,%ecx
mov    %r13,%r9
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,0x8(%rsp)
test   %ebx,%ebx
jle    1281 <TestPutCharIntoArrayEx+0xe1>
test   %r14,%r14
je     1281 <TestPutCharIntoArrayEx+0xe1>
mov    0x8(%rsp),%r13d
lea    0x1f(%rsp),%r12
lea    0xdf6(%rip),%rbx
xor    %ebp,%ebp
nop
movsbl (%r14,%rbp,1),%edi
movzbl %dil,%r15d
mov    %r12,%rsi
mov    $0x9,%edx
call   10a0 <BinString@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1250 <TestPutCharIntoArrayEx+0xb0>
mov    %r14,%rdi
mov    0x8(%rsp),%r15d
mov    %r15d,%esi
mov    0x14(%rsp),%edx
call   1040 <PutCharIntoArray@plt>
mov    %eax,%ebx
lea    0xdc1(%rip),%rdi
mov    %eax,%esi
mov    0x18(%rsp),%ebp
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
cmp    %ebp,%ebx
sete   %dil
call   1080 <assert@plt>
test   %ebp,%ebp
jne    13bc <TestPutCharIntoArrayEx+0x21c>
lea    0xdec(%rip),%rdi
call   1050 <puts@plt>
lea    0xe0b(%rip),%rdi
call   1050 <puts@plt>
test   %r15d,%r15d
jle    13ae <TestPutCharIntoArrayEx+0x20e>
mov    0x60(%rsp),%rbx
mov    %r15d,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%r13d
xor    %ebp,%ebp
jmp    1313 <TestPutCharIntoArrayEx+0x173>
nopw   0x0(%rax,%rax,1)
movzbl %r12b,%r13d
add    $0x1,%rbp
cmp    %rbp,0x8(%rsp)
je     13b4 <TestPutCharIntoArrayEx+0x214>
movsbl (%rbx,%rbp,1),%edi
movzbl %dil,%r15d
lea    0x1f(%rsp),%rsi
mov    $0x9,%edx
call   10a0 <BinString@plt>
xor    %r12d,%r12d
lea    0xd46(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
movsbl (%r14,%rbp,1),%edi
mov    %rbx,%r15
movzbl %dil,%ebx
lea    0x1f(%rsp),%rsi
mov    $0x9,%edx
call   10a0 <BinString@plt>
lea    0xd32(%rip),%rdi
mov    %ebx,%esi
mov    %r15,%rbx
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
movzbl (%r14,%rbp,1),%eax
cmp    (%r15,%rbp,1),%al
lea    0xd2b(%rip),%rdi
lea    0xd1f(%rip),%rax
cmove  %rax,%rdi
call   1050 <puts@plt>
test   %r13d,%r13d
je     1300 <TestPutCharIntoArrayEx+0x160>
movzbl (%r14,%rbp,1),%eax
cmp    (%rbx,%rbp,1),%al
sete   %r12b
jmp    1300 <TestPutCharIntoArrayEx+0x160>
mov    $0x1,%r13d
mov    %r13d,%edi
call   1080 <assert@plt>
test   %r14,%r14
je     13c9 <TestPutCharIntoArrayEx+0x229>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [67 x i8] c"\0A[%s:%d]\0APut char (0x%02x) '%c' into array (0x%p) of size (%d): {\0A\00"
@.str.1 = [28 x i8] c" [%2d]: (0x%02.2x) \22%s\22\0A\00"
@.str.2 = [27 x i8] c" } == %d : expecting %d\0A\00"
@.str.3 = [44 x i8] c"Compare resulting array to expected result\0A\00"
@.str.4 = [46 x i8] c" expected result\0A\00"
@.str.5 = [29 x i8] c" [%2d]: (0x%02.2x) \22%s\22 == \00"
@.str.6 = [19 x i8] c"(0x%02.2x) \22%s\22 : \00"
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.8 = [5 x i8] c"true\00"
@.str.9 = [6 x i8] c"false\00"
define void @TestPutCharIntoArrayEx(i8* %0, i32 %1, i8* %2, i32 %3, i8 signext %4, i32 %5, i8* %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca [9 x i8]
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i8 %4, i8* %12
store i32 %5, i32* %13
store i8* %6, i8** %14
store i8* null, i8** %15
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
%20 = getelementptr inbounds [9 x i8], [9 x i8]* %19, i64 0, i64 0
%21 = call i32 @memset(i8* %20, i32 0, i32 9)
%22 = load i8*, i8** %10
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %38
24: ; preds = %7
%25 = load i32, i32* %11
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %38
27: ; preds = %24
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = mul i64 1, %29
%31 = trunc i64 %30 to i32
%32 = call i64 @malloc(i32 %31)
%33 = inttoptr i64 %32 to i8*
store i8* %33, i8** %15
%34 = load i8*, i8** %15
%35 = load i8*, i8** %10
%36 = load i32, i32* %11
%37 = call i32 @memcpy(i8* %34, i8* %35, i32 %36)
br label %38
38: ; preds = %27, %24, %7
%39 = load i8*, i8** %8
%40 = load i32, i32* %9
%41 = load i8, i8* %12
%42 = sext i8 %41 to i32
%43 = load i8, i8* %12
%44 = call i64 @isprint(i8 signext %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %38
%47 = load i8, i8* %12
%48 = sext i8 %47 to i32
br label %50
49: ; preds = %38
br label %50
50: ; preds = %49, %46
%51 = phi i32 [ %48, %46 ], [ 46, %49 ]
%52 = load i8*, i8** %10
%53 = load i32, i32* %11
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i8* %39, i32 %40, i32 %42, i32 %51, i8* %52, i32 %53)
%55 = load i8*, i8** %15
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %86
57: ; preds = %50
%58 = load i32, i32* %11
%59 = icmp sge i32 %58, 1
br i1 %59, label %60, label %86
60: ; preds = %57
store i32 0, i32* %17
br label %61
61: ; preds = %82, %60
%62 = load i32, i32* %17
%63 = load i32, i32* %11
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %85
65: ; preds = %61
%66 = load i32, i32* %17
%67 = load i8*, i8** %15
%68 = load i32, i32* %17
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = and i32 %72, 255
%74 = load i8*, i8** %15
%75 = load i32, i32* %17
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %74, i64 %76
%78 = load i8, i8* %77
%79 = getelementptr inbounds [9 x i8], [9 x i8]* %19, i64 0, i64 0
%80 = call i8* @BinString(i8 signext %78, i8* %79, i32 9)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %66, i32 %73, i8* %80)
br label %82
82: ; preds = %65
%83 = load i32, i32* %17
%84 = add nsw i32 %83, 1
store i32 %84, i32* %17
br label %61
85: ; preds = %61
br label %86
86: ; preds = %85, %57, %50
%87 = load i8*, i8** %15
%88 = load i32, i32* %11
%89 = load i8, i8* %12
%90 = call i32 @PutCharIntoArray(i8* %87, i32 %88, i8 signext %89)
store i32 %90, i32* %16
%91 = load i32, i32* %16
%92 = load i32, i32* %13
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %91, i32 %92)
%94 = load i32, i32* %16
%95 = load i32, i32* %13
%96 = icmp eq i32 %94, %95
%97 = zext i1 %96 to i32
%98 = call i32 @assert(i32 %97)
%99 = load i32, i32* %13
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %183
101: ; preds = %86
store i32 1, i32* %18
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %17
br label %104
104: ; preds = %175, %101
%105 = load i32, i32* %17
%106 = load i32, i32* %11
%107 = icmp slt i32 %105, %106
br i1 %107, label %108, label %178
108: ; preds = %104
%109 = load i32, i32* %17
%110 = load i8*, i8** %14
%111 = load i32, i32* %17
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i8, i8* %110, i64 %112
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = and i32 %115, 255
%117 = load i8*, i8** %14
%118 = load i32, i32* %17
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8, i8* %117, i64 %119
%121 = load i8, i8* %120
%122 = getelementptr inbounds [9 x i8], [9 x i8]* %19, i64 0, i64 0
%123 = call i8* @BinString(i8 signext %121, i8* %122, i32 9)
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %109, i32 %116, i8* %123)
%125 = load i8*, i8** %15
%126 = load i32, i32* %17
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i8, i8* %125, i64 %127
%129 = load i8, i8* %128
%130 = sext i8 %129 to i32
%131 = and i32 %130, 255
%132 = load i8*, i8** %15
%133 = load i32, i32* %17
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8, i8* %132, i64 %134
%136 = load i8, i8* %135
%137 = getelementptr inbounds [9 x i8], [9 x i8]* %19, i64 0, i64 0
%138 = call i8* @BinString(i8 signext %136, i8* %137, i32 9)
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %131, i8* %138)
%140 = load i8*, i8** %15
%141 = load i32, i32* %17
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds i8, i8* %140, i64 %142
%144 = load i8, i8* %143
%145 = sext i8 %144 to i32
%146 = load i8*, i8** %14
%147 = load i32, i32* %17
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i8, i8* %146, i64 %148
%150 = load i8, i8* %149
%151 = sext i8 %150 to i32
%152 = icmp eq i32 %145, %151
%153 = zext i1 %152 to i64
%154 = select i1 %152, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0)
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %154)
%156 = load i32, i32* %18
%157 = icmp ne i32 %156, 0
br i1 %157, label %158, label %172
158: ; preds = %108
%159 = load i8*, i8** %15
%160 = load i32, i32* %17
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds i8, i8* %159, i64 %161
%163 = load i8, i8* %162
%164 = sext i8 %163 to i32
%165 = load i8*, i8** %14
%166 = load i32, i32* %17
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds i8, i8* %165, i64 %167
%169 = load i8, i8* %168
%170 = sext i8 %169 to i32
%171 = icmp eq i32 %164, %170
br label %172
172: ; preds = %158, %108
%173 = phi i1 [ false, %108 ], [ %171, %158 ]
%174 = zext i1 %173 to i32
store i32 %174, i32* %18
br label %175
175: ; preds = %172
%176 = load i32, i32* %17
%177 = add nsw i32 %176, 1
store i32 %177, i32* %17
br label %104
178: ; preds = %104
%179 = load i32, i32* %18
%180 = icmp ne i32 %179, 0
%181 = zext i1 %180 to i32
%182 = call i32 @assert(i32 %181)
br label %183
183: ; preds = %178, %86
%184 = load i8*, i8** %15
%185 = icmp ne i8* %184, null
br i1 %185, label %186, label %189
186: ; preds = %183
%187 = load i8*, i8** %15
%188 = call i32 @free(i8* %187)
store i8* null, i8** %15
br label %189
189: ; preds = %186, %183
ret void
}

LLVM IR (-O2):
@.str = [67 x i8] c"\0A[%s:%d]\0APut char (0x%02x) '%c' into array (0x%p) of size (%d): {\0A\00"
@.str.1 = [28 x i8] c" [%2d]: (0x%02.2x) \22%s\22\0A\00"
@.str.2 = [27 x i8] c" } == %d : expecting %d\0A\00"
@.str.5 = [29 x i8] c" [%2d]: (0x%02.2x) \22%s\22 == \00"
@.str.6 = [19 x i8] c"(0x%02.2x) \22%s\22 : \00"
@.str.8 = [5 x i8] c"true\00"
@.str.9 = [6 x i8] c"false\00"
@str = [43 x i8] c"Compare resulting array to expected result\00"
@str.10 = [45 x i8] c" expected result\00"
define void @TestPutCharIntoArrayEx(i8* %0, i32 %1, i8* %2, i32 %3, i8 signext %4, i32 %5, i8* nocapture %6) {
%8 = alloca [9 x i8]
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i32 0, i32 9)
%11 = icmp ne i8* %2, null
%12 = icmp sgt i32 %3, 0
%13 = and i1 %11, %12
br i1 %13, label %14, label %18
14: ; preds = %7
%15 = call i64 @malloc(i32 %3)
%16 = inttoptr i64 %15 to i8*
%17 = call i32 @memcpy(i8* %16, i8* %2, i32 %3)
br label %18
18: ; preds = %14, %7
%19 = phi i8* [ %16, %14 ], [ null, %7 ]
%20 = sext i8 %4 to i32
%21 = call i64 @isprint(i8 signext %4)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i32 46, i32 %20
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i32 %20, i32 %23, i8* %2, i32 %3)
%25 = icmp ne i8* %19, null
%26 = and i1 %12, %25
br i1 %26, label %27, label %39
27: ; preds = %18
%28 = zext i32 %3 to i64
br label %29
29: ; preds = %27, %29
%30 = phi i64 [ 0, %27 ], [ %37, %29 ]
%31 = getelementptr inbounds i8, i8* %19, i64 %30
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = call i8* @BinString(i8 signext %32, i8* %9, i32 9)
%35 = trunc i64 %30 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %33, i8* %34)
%37 = add nuw nsw i64 %30, 1
%38 = icmp eq i64 %37, %28
br i1 %38, label %39, label %29
39: ; preds = %29, %18
%40 = call i32 @PutCharIntoArray(i8* %19, i32 %3, i8 signext %4)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %5)
%42 = icmp eq i32 %40, %5
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = icmp eq i32 %5, 0
br i1 %45, label %46, label %83
46: ; preds = %39
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.10, i64 0, i64 0))
br i1 %12, label %49, label %80
49: ; preds = %46
%50 = zext i32 %3 to i64
br label %51
51: ; preds = %49, %75
%52 = phi i64 [ 0, %49 ], [ %78, %75 ]
%53 = phi i32 [ 1, %49 ], [ %77, %75 ]
%54 = getelementptr inbounds i8, i8* %6, i64 %52
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = call i8* @BinString(i8 signext %55, i8* %9, i32 9)
%58 = trunc i64 %52 to i32
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %58, i32 %56, i8* %57)
%60 = getelementptr inbounds i8, i8* %19, i64 %52
%61 = load i8, i8* %60
%62 = zext i8 %61 to i32
%63 = call i8* @BinString(i8 signext %61, i8* %9, i32 9)
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %62, i8* %63)
%65 = load i8, i8* %60
%66 = load i8, i8* %54
%67 = icmp eq i8 %65, %66
%68 = select i1 %67, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0)
%69 = call i32 @puts(i8* dereferenceable(1) %68)
%70 = icmp eq i32 %53, 0
br i1 %70, label %75, label %71
71: ; preds = %51
%72 = load i8, i8* %60
%73 = load i8, i8* %54
%74 = icmp eq i8 %72, %73
br label %75
75: ; preds = %71, %51
%76 = phi i1 [ false, %51 ], [ %74, %71 ]
%77 = zext i1 %76 to i32
%78 = add nuw nsw i64 %52, 1
%79 = icmp eq i64 %78, %50
br i1 %79, label %80, label %51
80: ; preds = %75, %46
%81 = phi i32 [ 1, %46 ], [ %77, %75 ]
%82 = call i32 @assert(i32 %81)
br label %83
83: ; preds = %80, %39
br i1 %25, label %84, label %86
84: ; preds = %83
%85 = call i32 @free(i8* %19)
br label %86
86: ; preds = %84, %83
ret void
}