#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 */
struct tok {
  int dummy;
};
struct cfgerror {
  int dummy;
};

/* Variables and functions */
scalar_t__ checkargs(struct tok *, struct cfgerror *);
scalar_t__ checkdatatype(struct tok *, struct cfgerror *);
scalar_t__ checktokenlist(struct tok *, struct cfgerror *);
scalar_t__ countbraces(struct tok *, struct cfgerror *);
int validatetokens(struct tok *tokens, struct cfgerror *er) {
  if (countbraces(tokens, er) != 0)
    return (-1);
  if (checktokenlist(tokens, er) != 0)
    return (-1);
  if (checkdatatype(tokens, er) != 0)
    return (-1);
  if (checkargs(tokens, er) != 0)
    return (-1);
  return (0);
}


x86 assembly (clang, -O0):
<validatetokens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <countbraces@plt>
cmp    $0x0,%rax
je     1173 <validatetokens+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e3 <validatetokens+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <checktokenlist@plt>
cmp    $0x0,%rax
je     1196 <validatetokens+0x56>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e3 <validatetokens+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <checkdatatype@plt>
cmp    $0x0,%rax
je     11b9 <validatetokens+0x79>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e3 <validatetokens+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <checkargs@plt>
cmp    $0x0,%rax
je     11dc <validatetokens+0x9c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e3 <validatetokens+0xa3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validatetokens>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1060 <countbraces@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
jne    118b <validatetokens+0x4b>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <checktokenlist@plt>
test   %rax,%rax
jne    118b <validatetokens+0x4b>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <checkdatatype@plt>
test   %rax,%rax
jne    118b <validatetokens+0x4b>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <checkargs@plt>
neg    %rax
sbb    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tok = type { i32 }
%struct.cfgerror = type { i32 }
define i32 @validatetokens(%struct.tok* %0, %struct.cfgerror* %1) {
%3 = alloca i32
%4 = alloca %struct.tok*
%5 = alloca %struct.cfgerror*
store %struct.tok* %0, %struct.tok** %4
store %struct.cfgerror* %1, %struct.cfgerror** %5
%6 = load %struct.tok*, %struct.tok** %4
%7 = load %struct.cfgerror*, %struct.cfgerror** %5
%8 = call i64 @countbraces(%struct.tok* %6, %struct.cfgerror* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %30
11: ; preds = %2
%12 = load %struct.tok*, %struct.tok** %4
%13 = load %struct.cfgerror*, %struct.cfgerror** %5
%14 = call i64 @checktokenlist(%struct.tok* %12, %struct.cfgerror* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 -1, i32* %3
br label %30
17: ; preds = %11
%18 = load %struct.tok*, %struct.tok** %4
%19 = load %struct.cfgerror*, %struct.cfgerror** %5
%20 = call i64 @checkdatatype(%struct.tok* %18, %struct.cfgerror* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 -1, i32* %3
br label %30
23: ; preds = %17
%24 = load %struct.tok*, %struct.tok** %4
%25 = load %struct.cfgerror*, %struct.cfgerror** %5
%26 = call i64 @checkargs(%struct.tok* %24, %struct.cfgerror* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 -1, i32* %3
br label %30
29: ; preds = %23
store i32 0, i32* %3
br label %30
30: ; preds = %29, %28, %22, %16, %10
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
%struct.tok = type { i32 }
%struct.cfgerror = type { i32 }
define i32 @validatetokens(%struct.tok* %0, %struct.cfgerror* %1) {
%3 = tail call i64 @countbraces(%struct.tok* %0, %struct.cfgerror* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = tail call i64 @checktokenlist(%struct.tok* %0, %struct.cfgerror* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = tail call i64 @checkdatatype(%struct.tok* %0, %struct.cfgerror* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call i64 @checkargs(%struct.tok* %0, %struct.cfgerror* %1)
%13 = icmp ne i64 %12, 0
%14 = sext i1 %13 to i32
br label %15
15: ; preds = %11, %8, %5, %2
%16 = phi i32 [ -1, %2 ], [ -1, %5 ], [ -1, %8 ], [ %14, %11 ]
ret i32 %16
}