#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*/ printf(char *, int, char, char, int);
int verify(char *buf, char val, int size, int child) {
  while (size-- > 0) {
    if (*buf++ != val) {
      printf("Verify error in child %d, *buf = %x, val = %x, size = %d\n",
             child, *buf, val, size);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
jle    118d <verify+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
je     1188 <verify+0x78>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%r8d
lea    0xe8f(%rip),%rdi
movsbl %cl,%edx
movsbl %al,%ecx
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1194 <verify+0x84>
jmp    1128 <verify+0x18>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify>:
push   %rax
mov    %edx,%r8d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %r8d,%r8d
jle    1153 <verify+0x43>
lea    0x1(%rdi),%rax
add    $0xffffffff,%r8d
cmp    %sil,(%rdi)
mov    %rax,%rdi
je     1120 <verify+0x10>
movsbl (%rax),%edx
movsbl %sil,%eax
lea    0xebd(%rip),%rdi
mov    %ecx,%esi
mov    %eax,%ecx
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [58 x i8] c"Verify error in child %d, *buf = %x, val = %x, size = %d\0A\00"
define i32 @verify(i8* %0, i8 signext %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %6
store i8 %1, i8* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
br label %10
10: ; preds = %29, %4
%11 = load i32, i32* %8
%12 = add nsw i32 %11, -1
store i32 %12, i32* %8
%13 = icmp sgt i32 %11, 0
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %6
%17 = load i8, i8* %15
%18 = sext i8 %17 to i32
%19 = load i8, i8* %7
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %18, %20
br i1 %21, label %22, label %29
22: ; preds = %14
%23 = load i32, i32* %9
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = load i8, i8* %7
%27 = load i32, i32* %8
%28 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %23, i8 signext %25, i8 signext %26, i32 %27)
store i32 1, i32* %5
br label %31
29: ; preds = %14
br label %10
30: ; preds = %10
store i32 0, i32* %5
br label %31
31: ; preds = %30, %22
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
@.str = [58 x i8] c"Verify error in child %d, *buf = %x, val = %x, size = %d\0A\00"
define i32 @verify(i8* nocapture %0, i8 signext %1, i32 %2, i32 %3) {
br label %5
5: ; preds = %10, %4
%6 = phi i8* [ %0, %4 ], [ %11, %10 ]
%7 = phi i32 [ %2, %4 ], [ %8, %10 ]
%8 = add nsw i32 %7, -1
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %17
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %6, i64 1
%12 = load i8, i8* %6
%13 = icmp eq i8 %12, %1
br i1 %13, label %5, label %14
14: ; preds = %10
%15 = load i8, i8* %11
%16 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %3, i8 signext %15, i8 signext %1, i32 %8)
br label %17
17: ; preds = %5, %14
%18 = phi i32 [ 1, %14 ], [ 0, %5 ]
ret i32 %18
}