#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*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ xbzero(void *, int);
void test2(size_t size) {
  int *arr = (int *)malloc(sizeof(int) * size);
  xbzero((void *)arr, sizeof(int) * size);
  for (size_t i = 0; i < size; i++) {
    if (arr[i] != 0) {
      printf("Not zero!!\n");
    }
  }
  free(arr);
  printf("Yes\n");
}


x86 assembly (clang, -O0):
<test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1050 <xbzero@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11bc <test2+0x7c>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11a6 <test2+0x66>
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
jmp    11ab <test2+0x6b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    117a <test2+0x3a>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x0(,%rdi,4),%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
call   1050 <xbzero@plt>
test   %r14,%r14
je     1199 <test2+0x59>
xor    %ebp,%ebp
lea    0xe91(%rip),%r15
jmp    1189 <test2+0x49>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbp
cmp    %rbp,%r14
je     1199 <test2+0x59>
cmpl   $0x0,(%rbx,%rbp,4)
je     1180 <test2+0x40>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    1180 <test2+0x40>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe58(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"Not zero!!\0A\00"
@.str.1 = [5 x i8] c"Yes\0A\00"
define void @test2(i64 %0) {
%2 = alloca i64
%3 = alloca i32*
%4 = alloca i64
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = mul i64 4, %5
%7 = trunc i64 %6 to i32
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i32*
store i32* %9, i32** %3
%10 = load i32*, i32** %3
%11 = bitcast i32* %10 to i8*
%12 = load i64, i64* %2
%13 = mul i64 4, %12
%14 = trunc i64 %13 to i32
%15 = call i32 @xbzero(i8* %11, i32 %14)
store i64 0, i64* %4
br label %16
16: ; preds = %29, %1
%17 = load i64, i64* %4
%18 = load i64, i64* %2
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = load i32*, i32** %3
%22 = load i64, i64* %4
%23 = getelementptr inbounds i32, i32* %21, i64 %22
%24 = load i32, i32* %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %20
br label %29
29: ; preds = %28
%30 = load i64, i64* %4
%31 = add i64 %30, 1
store i64 %31, i64* %4
br label %16
32: ; preds = %16
%33 = load i32*, i32** %3
%34 = call i32 @free(i32* %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [4 x i8] c"Yes\00"
@str.2 = [11 x i8] c"Not zero!!\00"
define void @test2(i64 %0) {
%2 = trunc i64 %0 to i32
%3 = shl i32 %2, 2
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i32*
%6 = inttoptr i64 %4 to i8*
%7 = tail call i32 @xbzero(i8* %6, i32 %3)
%8 = icmp eq i64 %0, 0
br i1 %8, label %9, label %12
9: ; preds = %19, %1
%10 = tail call i32 @free(i32* %5)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret void
12: ; preds = %1, %19
%13 = phi i64 [ %20, %19 ], [ 0, %1 ]
%14 = getelementptr inbounds i32, i32* %5, i64 %13
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.2, i64 0, i64 0))
br label %19
19: ; preds = %12, %17
%20 = add nuw i64 %13, 1
%21 = icmp eq i64 %20, %0
br i1 %21, label %9, label %12
}