#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 */
scalar_t__ bar1(int *);
int bar2(char *);
int foo(void) {
  int len;
  if (bar1(&len)) {
    char devpath[len];
    if (bar2(devpath) == len)
      return len;
  }
  return -1;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
call   1040 <bar1@plt>
cmp    $0x0,%rax
je     11a5 <foo+0x85>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
call   1030 <bar2@plt>
cmp    -0x8(%rbp),%eax
jne    117d <foo+0x5d>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    1184 <foo+0x64>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x1c(%rbp),%eax
test   %eax,%eax
je     11a0 <foo+0x80>
jmp    119b <foo+0x7b>
jmp    11ac <foo+0x8c>
jmp    11a5 <foo+0x85>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
lea    -0xc(%rbp),%rdi
call   1040 <bar1@plt>
test   %rax,%rax
je     1158 <foo+0x38>
mov    %rsp,%rbx
mov    -0xc(%rbp),%eax
mov    %rsp,%rdi
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdi
mov    %rdi,%rsp
call   1030 <bar2@plt>
cmp    -0xc(%rbp),%eax
mov    %rbx,%rsp
je     115d <foo+0x3d>
mov    $0xffffffff,%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @foo() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = call i64 @bar1(i32* %2)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %23
8: ; preds = %0
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %3
%12 = alloca i8, i64 %10
store i64 %10, i64* %4
%13 = call i32 @bar2(i8* %12)
%14 = load i32, i32* %2
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = load i32, i32* %2
store i32 %17, i32* %1
store i32 1, i32* %5
br label %19
18: ; preds = %8
store i32 0, i32* %5
br label %19
19: ; preds = %18, %16
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
switch i32 %21, label %26 [
i32 0, label %22
i32 1, label %24
]
22: ; preds = %19
br label %23
23: ; preds = %22, %0
store i32 -1, i32* %1
br label %24
24: ; preds = %23, %19
%25 = load i32, i32* %1
ret i32 %25
26: ; preds = %19
unreachable
}

LLVM IR (-O2):
define i32 @foo() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @bar1(i32* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %0
%6 = load i32, i32* %1
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
%9 = alloca i8, i64 %7
%10 = call i32 @bar2(i8* %9)
%11 = load i32, i32* %1
%12 = icmp eq i32 %10, %11
br i1 %12, label %14, label %13
13: ; preds = %5, %0
br label %14
14: ; preds = %5, %13
%15 = phi i32 [ -1, %13 ], [ %10, %5 ]
ret i32 %15
}