#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*/ bar(char **);
__attribute__((nonnull(1, 3))) int foo(char *cp1, char *cp2, char *cp3,
                                       char *cp4) {
  if (cp1 == (char *)0)
    return 1;
  cp1 = cp2;
  if (cp1 == (char *)0)
    return 2;
  if (!cp4)
    return 3;
  char **p = &cp3;
  bar(p);
  if (cp3 == (char *)0)
    return 4;
  return 5;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113f <foo+0x2f>
movl   $0x1,-0x4(%rbp)
jmp    11a4 <foo+0x94>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115e <foo+0x4e>
movl   $0x2,-0x4(%rbp)
jmp    11a4 <foo+0x94>
cmpq   $0x0,-0x28(%rbp)
jne    1175 <foo+0x65>
movl   $0x3,-0x4(%rbp)
jmp    11a4 <foo+0x94>
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <bar@plt>
cmpq   $0x0,-0x20(%rbp)
jne    119d <foo+0x8d>
movl   $0x4,-0x4(%rbp)
jmp    11a4 <foo+0x94>
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rax
mov    %rdx,(%rsp)
test   %rsi,%rsi
je     1136 <foo+0x26>
test   %rcx,%rcx
je     113d <foo+0x2d>
mov    %rsp,%rdi
call   1030 <bar@plt>
cmpq   $0x1,(%rsp)
mov    $0x5,%eax
sbb    $0x0,%eax
pop    %rcx
ret
mov    $0x2,%eax
pop    %rcx
ret
mov    $0x3,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @foo(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8**
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%11 = load i8*, i8** %6
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %4
store i32 1, i32* %5
br label %30
14: ; preds = %4
%15 = load i8*, i8** %7
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 2, i32* %5
br label %30
19: ; preds = %14
%20 = load i8*, i8** %9
%21 = icmp ne i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %19
store i32 3, i32* %5
br label %30
23: ; preds = %19
store i8** %8, i8*** %10
%24 = load i8**, i8*** %10
%25 = call i32 @bar(i8** %24)
%26 = load i8*, i8** %8
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 4, i32* %5
br label %30
29: ; preds = %23
store i32 5, i32* %5
br label %30
30: ; preds = %29, %28, %22, %18, %13
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
define i32 @foo(i8* nocapture readnone %0, i8* readnone %1, i8* %2, i8* readnone %3) {
%5 = alloca i8*
store i8* %2, i8** %5
%6 = icmp eq i8* %1, null
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = icmp eq i8* %3, null
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = call i32 @bar(i8** %5)
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
%13 = select i1 %12, i32 4, i32 5
br label %14
14: ; preds = %7, %4, %9
%15 = phi i32 [ %13, %9 ], [ 2, %4 ], [ 3, %7 ]
ret i32 %15
}