#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);
int validData(int **bufferframefull, int bufferframe, int numthreads,
              int verbose) {
  int i;
  if (verbose) {
    printf("Looking at bufferframe %d\n", bufferframe);
  }
  for (i = 0; i < numthreads; ++i) {
    if (!bufferframefull[i][bufferframe])
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<validData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     113e <validData+0x2e>
mov    -0x14(%rbp),%esi
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    118a <validData+0x7a>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1177 <validData+0x67>
movl   $0x0,-0x4(%rbp)
jmp    1191 <validData+0x81>
jmp    117c <validData+0x6c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1145 <validData+0x35>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validData>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
test   %ecx,%ecx
je     112f <validData+0x1f>
lea    0xed9(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
mov    $0x1,%eax
test   %ebp,%ebp
jle    1157 <validData+0x47>
movslq %r14d,%rcx
mov    %ebp,%edx
xor    %esi,%esi
nop
mov    (%rbx,%rsi,8),%rdi
cmpl   $0x0,(%rdi,%rcx,4)
je     1155 <validData+0x45>
add    $0x1,%rsi
cmp    %rsi,%rdx
jne    1140 <validData+0x30>
jmp    1157 <validData+0x47>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [27 x i8] c"Looking at bufferframe %d\0A\00"
define i32 @validData(i32** nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %8
8: ; preds = %6, %4
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %23
10: ; preds = %8
%11 = sext i32 %1 to i64
%12 = zext i32 %2 to i64
br label %15
13: ; preds = %15
%14 = icmp eq i64 %22, %12
br i1 %14, label %23, label %15
15: ; preds = %10, %13
%16 = phi i64 [ 0, %10 ], [ %22, %13 ]
%17 = getelementptr inbounds i32*, i32** %0, i64 %16
%18 = load i32*, i32** %17
%19 = getelementptr inbounds i32, i32* %18, i64 %11
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 0
%22 = add nuw nsw i64 %16, 1
br i1 %21, label %23, label %13
23: ; preds = %15, %13, %8
%24 = phi i32 [ 1, %8 ], [ 1, %13 ], [ 0, %15 ]
ret i32 %24
}