#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 kcn_uri {
  int dummy;
};

/* Variables and functions */
scalar_t__ kcn_uri_encputs(struct kcn_uri *, char const *);
scalar_t__ kcn_uri_puts(struct kcn_uri *, char const *);
bool kcn_uri_param_puts(struct kcn_uri *ku, const char *param,
                        const char *val) {
  if (val == NULL)
    return true;
  if (kcn_uri_puts(ku, "&") && kcn_uri_puts(ku, param) &&
      kcn_uri_puts(ku, "=") && kcn_uri_encputs(ku, val))
    return true;
  else
    return false;
}


x86 assembly (clang, -O0):
<kcn_uri_param_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    114b <kcn_uri_param_puts+0x2b>
movl   $0x1,-0x4(%rbp)
jmp    11c0 <kcn_uri_param_puts+0xa0>
mov    -0x10(%rbp),%rdi
lea    0xeaa(%rip),%rsi
call   1040 <kcn_uri_puts@plt>
cmp    $0x0,%rax
je     11b9 <kcn_uri_param_puts+0x99>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <kcn_uri_puts@plt>
cmp    $0x0,%rax
je     11b9 <kcn_uri_param_puts+0x99>
mov    -0x10(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <kcn_uri_puts@plt>
cmp    $0x0,%rax
je     11b9 <kcn_uri_param_puts+0x99>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <kcn_uri_encputs@plt>
cmp    $0x0,%rax
je     11b9 <kcn_uri_param_puts+0x99>
movl   $0x1,-0x4(%rbp)
jmp    11c0 <kcn_uri_param_puts+0xa0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kcn_uri_param_puts>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r14d
test   %rdx,%rdx
je     1183 <kcn_uri_param_puts+0x63>
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0xebe(%rip),%rsi
call   1040 <kcn_uri_puts@plt>
test   %rax,%rax
je     1180 <kcn_uri_param_puts+0x60>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1040 <kcn_uri_puts@plt>
test   %rax,%rax
je     1180 <kcn_uri_param_puts+0x60>
lea    0xe9f(%rip),%rsi
mov    %rbp,%rdi
call   1040 <kcn_uri_puts@plt>
test   %rax,%rax
je     1180 <kcn_uri_param_puts+0x60>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <kcn_uri_encputs@plt>
test   %rax,%rax
jne    1183 <kcn_uri_param_puts+0x63>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.kcn_uri = type { i32 }
@.str = [2 x i8] c"&\00"
@.str.1 = [2 x i8] c"=\00"
define i32 @kcn_uri_param_puts(%struct.kcn_uri* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.kcn_uri*
%6 = alloca i8*
%7 = alloca i8*
store %struct.kcn_uri* %0, %struct.kcn_uri** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %3
store i32 1, i32* %4
br label %31
11: ; preds = %3
%12 = load %struct.kcn_uri*, %struct.kcn_uri** %5
%13 = call i64 @kcn_uri_puts(%struct.kcn_uri* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = load %struct.kcn_uri*, %struct.kcn_uri** %5
%17 = load i8*, i8** %6
%18 = call i64 @kcn_uri_puts(%struct.kcn_uri* %16, i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %15
%21 = load %struct.kcn_uri*, %struct.kcn_uri** %5
%22 = call i64 @kcn_uri_puts(%struct.kcn_uri* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load %struct.kcn_uri*, %struct.kcn_uri** %5
%26 = load i8*, i8** %7
%27 = call i64 @kcn_uri_encputs(%struct.kcn_uri* %25, i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 1, i32* %4
br label %31
30: ; preds = %24, %20, %15, %11
store i32 0, i32* %4
br label %31
31: ; preds = %30, %29, %10
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
%struct.kcn_uri = type { i32 }
@.str = [2 x i8] c"&\00"
@.str.1 = [2 x i8] c"=\00"
define i32 @kcn_uri_param_puts(%struct.kcn_uri* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = tail call i64 @kcn_uri_puts(%struct.kcn_uri* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %5
%9 = tail call i64 @kcn_uri_puts(%struct.kcn_uri* %0, i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = tail call i64 @kcn_uri_puts(%struct.kcn_uri* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = tail call i64 @kcn_uri_encputs(%struct.kcn_uri* %0, i8* %2)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14, %11, %8, %5
br label %18
18: ; preds = %14, %3, %17
%19 = phi i32 [ 0, %17 ], [ 1, %3 ], [ 1, %14 ]
ret i32 %19
}