#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__ strcmp(char *, char *);
scalar_t__ strlen(char *);
int comp_str(char *a, char *b) {
  if (a == NULL || b == NULL) {
    return 0;
  }
  if (strlen(a) != strlen(b)) {
    return 0;
  }
  return strcmp(a, b) == 0;
}


x86 assembly (clang, -O0):
<comp_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <comp_str+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1152 <comp_str+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11a0 <comp_str+0x80>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     1184 <comp_str+0x64>
movl   $0x0,-0x4(%rbp)
jmp    11a0 <comp_str+0x80>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comp_str>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %rdi,%rdi
je     1164 <comp_str+0x44>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1164 <comp_str+0x44>
mov    %rdi,%rbp
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %rax,%r15
jne    1164 <comp_str+0x44>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
xor    %r14d,%r14d
test   %rax,%rax
sete   %r14b
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @comp_str(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = tail call i64 @strcmp(i8* %0, i8* %1)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %6, %2, %10
%15 = phi i32 [ %13, %10 ], [ 0, %2 ], [ 0, %6 ]
ret i32 %15
}