#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*/ printf(char *, ...);
scalar_t__ strcmp(char const *, char const *);
int compare_strings_or_die(int linenum, const char *fmt, const char *s1,
                           const char *s2) {
  int errors = 0;
  if (strcmp(s1, s2) != 0) {
    printf("\n\nLine %d: string compare mismatch:\n\t", linenum);
    printf("\"%s\"\n", fmt);
    printf("\t\"%s\"\n\t\"%s\"\n", s1, s2);
    errors++;
  };
  return errors;
}


x86 assembly (clang, -O0):
<compare_strings_or_die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1197 <compare_strings_or_die+0x77>
mov    -0x4(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_strings_or_die>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %edi,%ebp
mov    %rdx,%rdi
mov    %rcx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     117e <compare_strings_or_die+0x5e>
lea    0xeb7(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
jmp    1180 <compare_strings_or_die+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"\0A\0ALine %d: string compare mismatch:\0A\09\00"
@.str.1 = [6 x i8] c"\22%s\22\0A\00"
@.str.2 = [13 x i8] c"\09\22%s\22\0A\09\22%s\22\0A\00"
define i32 @compare_strings_or_die(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %9
%10 = load i8*, i8** %7
%11 = load i8*, i8** %8
%12 = call i64 @strcmp(i8* %10, i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %4
%15 = load i32, i32* %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i8*, i8** %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %7
%20 = load i8*, i8** %8
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %20)
%22 = load i32, i32* %9
%23 = add nsw i32 %22, 1
store i32 %23, i32* %9
br label %24
24: ; preds = %14, %4
%25 = load i32, i32* %9
ret i32 %25
}

LLVM IR (-O2):
@.str = [38 x i8] c"\0A\0ALine %d: string compare mismatch:\0A\09\00"
@.str.1 = [6 x i8] c"\22%s\22\0A\00"
@.str.2 = [13 x i8] c"\09\22%s\22\0A\09\22%s\22\0A\00"
define i32 @compare_strings_or_die(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i64 @strcmp(i8* %2, i8* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %0)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %3)
br label %11
11: ; preds = %7, %4
%12 = phi i32 [ 1, %7 ], [ 0, %4 ]
ret i32 %12
}