#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int strlcat(char *, char *, int);
int main(void) {
  char buf[3] = "a";
  return (!(2 == strlcat(buf, "b", sizeof(buf)) && 'a' == buf[0] &&
            'b' == buf[1] && '\0' == buf[2]));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xed2(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0x7(%rbp),%rdi
lea    0xec5(%rip),%rsi
mov    $0x3,%edx
call   1030 <strlcat@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x2,%ecx
cmp    %edx,%ecx
mov    %al,-0x8(%rbp)
jne    1196 <main+0x86>
movsbl -0x7(%rbp),%edx
xor    %eax,%eax
mov    $0x61,%ecx
cmp    %edx,%ecx
mov    %al,-0x8(%rbp)
jne    1196 <main+0x86>
movsbl -0x6(%rbp),%edx
xor    %eax,%eax
mov    $0x62,%ecx
cmp    %edx,%ecx
mov    %al,-0x8(%rbp)
jne    1196 <main+0x86>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movb   $0x0,0x6(%rsp)
movw   $0x61,0x4(%rsp)
lea    0xedf(%rip),%rsi
lea    0x4(%rsp),%rdi
mov    $0x3,%edx
call   1030 <strlcat@plt>
cmp    $0x2,%eax
setne  %al
cmpb   $0x61,0x4(%rsp)
setne  %cl
or     %al,%cl
cmpb   $0x62,0x5(%rsp)
setne  %al
cmpb   $0x0,0x6(%rsp)
setne  %dl
or     %al,%dl
or     %cl,%dl
movzbl %dl,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.buf = [3 x i8] c"a\00\00"
@.str = [2 x i8] c"b\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8]
store i32 0, i32* %1
%3 = bitcast [3 x i8]* %2 to i8*
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%5 = call i32 @strlcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 3)
%6 = icmp eq i32 2, %5
br i1 %6, label %7, label %22
7: ; preds = %0
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 97, %10
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 98, %15
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 0, %20
br label %22
22: ; preds = %17, %12, %7, %0
%23 = phi i1 [ false, %12 ], [ false, %7 ], [ false, %0 ], [ %21, %17 ]
%24 = xor i1 %23, true
%25 = zext i1 %24 to i32
ret i32 %25
}

LLVM IR (-O2):
@__const.main.buf = [3 x i8] c"a\00\00"
@.str = [2 x i8] c"b\00"
define i32 @main() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 3)
%4 = icmp ne i32 %3, 2
%5 = load i8, i8* %2
%6 = icmp ne i8 %5, 97
%7 = select i1 %4, i1 true, i1 %6
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 1
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 98
%11 = select i1 %7, i1 true, i1 %10
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 2
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
%15 = select i1 %11, i1 true, i1 %14
%16 = zext i1 %15 to i32
ret i32 %16
}