#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*/ scanf(char *, int *, int *, int *);
int first(int *current, int cap) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  *current += b;
  return !a && b <= cap && (!c || b == cap);
}


x86 assembly (clang, -O0):
<first>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1030 <scanf@plt>
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x19(%rbp)
jne    1183 <first+0x73>
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x19(%rbp)
jg     1183 <first+0x73>
mov    $0x1,%al
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x1a(%rbp)
je     117d <first+0x6d>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<first>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xede(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1030 <scanf@plt>
mov    0x10(%rsp),%ecx
add    %ecx,(%rbx)
xor    %eax,%eax
cmpl   $0x0,0x14(%rsp)
jne    115b <first+0x4b>
cmp    %ebp,%ecx
jg     115b <first+0x4b>
cmpl   $0x0,0xc(%rsp)
sete   %al
cmp    %ebp,%ecx
sete   %cl
or     %al,%cl
movzbl %cl,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
define i32 @first(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7)
%9 = load i32, i32* %6
%10 = load i32*, i32** %3
%11 = load i32, i32* %10
%12 = add nsw i32 %11, %9
store i32 %12, i32* %10
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %28, label %15
15: ; preds = %2
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i32, i32* %7
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* %6
%24 = load i32, i32* %4
%25 = icmp eq i32 %23, %24
br label %26
26: ; preds = %22, %19
%27 = phi i1 [ true, %19 ], [ %25, %22 ]
br label %28
28: ; preds = %26, %15, %2
%29 = phi i1 [ false, %15 ], [ false, %2 ], [ %27, %26 ]
%30 = zext i1 %29 to i32
ret i32 %30
}

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