#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*/ bzero(char *, int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  char tmp[32];
  int i, j;
  memset(tmp, 0x55, 32);
  bzero(tmp, 32);
  j = 0;
  for (i = 0; i < 32; i++) {
    j += tmp[i];
  }
  if (j)
    printf("bzero failed!\r\n");
  else
    printf("bzero succeeded!\r\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x55,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1050 <bzero@plt>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x20,-0x34(%rbp)
jge    119c <main+0x6c>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1175 <main+0x45>
cmpl   $0x0,-0x38(%rbp)
je     11b7 <main+0x87>
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
jmp    11c3 <main+0x93>
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x55,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1050 <bzero@plt>
movdqa (%rsp),%xmm0
punpckhbw %xmm0,%xmm1
punpcklwd %xmm1,%xmm2
psrad  $0x18,%xmm2
punpcklbw %xmm0,%xmm0
punpcklwd %xmm0,%xmm3
psrad  $0x18,%xmm3
paddd  %xmm2,%xmm3
punpckhwd %xmm1,%xmm1
psrad  $0x18,%xmm1
punpckhwd %xmm0,%xmm0
psrad  $0x18,%xmm0
paddd  %xmm1,%xmm0
paddd  %xmm3,%xmm0
movq   0x10(%rsp),%xmm1
punpcklbw %xmm1,%xmm1
punpckhwd %xmm1,%xmm2
psrad  $0x18,%xmm2
punpcklwd %xmm1,%xmm1
psrad  $0x18,%xmm1
paddd  %xmm2,%xmm1
movsbl 0x18(%rsp),%eax
movsbl 0x19(%rsp),%ecx
movsbl 0x1a(%rsp),%edx
movsbl 0x1b(%rsp),%esi
movsbl 0x1c(%rsp),%r10d
movsbl 0x1d(%rsp),%r9d
movsbl 0x1e(%rsp),%r8d
pshufd $0xee,%xmm0,%xmm2
paddd  %xmm0,%xmm2
pshufd $0x55,%xmm2,%xmm0
paddd  %xmm2,%xmm0
movd   %xmm0,%ebx
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%edi
add    %ebx,%edi
add    %eax,%edi
add    %ecx,%edi
add    %edx,%edi
add    %esi,%edi
add    %r10d,%edi
add    %r9d,%edi
add    %r8d,%edi
movsbl 0x1f(%rsp),%eax
add    %edi,%eax
lea    0xdd9(%rip),%rax
lea    0xde4(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"bzero failed!\0D\0A\00"
@.str.1 = [19 x i8] c"bzero succeeded!\0D\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i32 85, i32 32)
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%12 = call i32 @bzero(i8* %11, i32 32)
store i32 0, i32* %8
store i32 0, i32* %7
br label %13
13: ; preds = %24, %2
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 32
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i32, i32* %8
%23 = add nsw i32 %22, %21
store i32 %23, i32* %8
br label %24
24: ; preds = %16
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %13
27: ; preds = %13
%28 = load i32, i32* %8
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %34
32: ; preds = %27
%33 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
ret i32 0
}

LLVM IR (-O2):
@str = [18 x i8] c"bzero succeeded!\0D\00"
@str.2 = [15 x i8] c"bzero failed!\0D\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 85, i32 32)
%6 = call i32 @bzero(i8* %4, i32 32)
%7 = bitcast [32 x i8]* %3 to <16 x i8>*
%8 = load <16 x i8>, <16 x i8>* %7
%9 = sext <16 x i8> %8 to <16 x i32>
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 16
%11 = bitcast i8* %10 to <8 x i8>*
%12 = load <8 x i8>, <8 x i8>* %11
%13 = sext <8 x i8> %12 to <8 x i32>
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 24
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 25
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 26
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 27
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 28
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 29
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 30
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %9)
%36 = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %13)
%37 = add nsw i32 %35, %36
%38 = add nsw i32 %37, %16
%39 = add nsw i32 %38, %19
%40 = add nsw i32 %39, %22
%41 = add nsw i32 %40, %25
%42 = add nsw i32 %41, %28
%43 = add nsw i32 %42, %31
%44 = add nsw i32 %43, %34
%45 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 31
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = sub nsw i32 0, %47
%49 = icmp eq i32 %44, %48
%50 = select i1 %49, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.2, i64 0, i64 0)
%51 = call i32 @puts(i8* dereferenceable(1) %50)
ret i32 0
}