#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 *, char *);
scalar_t__ strcmp(char *, char *);
void compare_and_print(char *ip1, char *ip2, char *ip3, int i) {
  printf("%15s ", ip1);
  if (strcmp(ip1, ip2) && i > 1)
    printf("%15s ", ip2);
  else if (strcmp(ip1, ip3) && i > 2)
    printf("%15s ", ip3);
  if (strcmp(ip1, ip3) && strcmp(ip2, ip3) && i > 2)
    printf("%15s ", ip3);
}


x86 assembly (clang, -O0):
<compare_and_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     117d <compare_and_print+0x5d>
cmpl   $0x1,-0x1c(%rbp)
jle    117d <compare_and_print+0x5d>
mov    -0x10(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
jmp    11b3 <compare_and_print+0x93>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11ae <compare_and_print+0x8e>
cmpl   $0x2,-0x1c(%rbp)
jle    11ae <compare_and_print+0x8e>
mov    -0x18(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
jmp    11b3 <compare_and_print+0x93>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11fb <compare_and_print+0xdb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11fb <compare_and_print+0xdb>
cmpl   $0x2,-0x1c(%rbp)
jle    11fb <compare_and_print+0xdb>
mov    -0x18(%rbp),%rsi
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_and_print>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xec6(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <strcmp@plt>
cmp    $0x2,%r14d
jl     115b <compare_and_print+0x3b>
mov    %rbp,%rsi
test   %rax,%rax
jne    1174 <compare_and_print+0x54>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
cmp    $0x3,%r14d
jl     1180 <compare_and_print+0x60>
mov    %r15,%rsi
test   %rax,%rax
je     1180 <compare_and_print+0x60>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11bf <compare_and_print+0x9f>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
cmp    $0x3,%r14d
jl     11bf <compare_and_print+0x9f>
test   %rax,%rax
je     11bf <compare_and_print+0x9f>
lea    0xe53(%rip),%rdi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%15s \00"
define void @compare_and_print(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = call i64 @strcmp(i8* %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %4
%16 = load i32, i32* %8
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i8*, i8** %6
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %33
21: ; preds = %15, %4
%22 = load i8*, i8** %5
%23 = load i8*, i8** %7
%24 = call i64 @strcmp(i8* %22, i8* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load i32, i32* %8
%28 = icmp sgt i32 %27, 2
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i8*, i8** %7
%31 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %29, %26, %21
br label %33
33: ; preds = %32, %18
%34 = load i8*, i8** %5
%35 = load i8*, i8** %7
%36 = call i64 @strcmp(i8* %34, i8* %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %49
38: ; preds = %33
%39 = load i8*, i8** %6
%40 = load i8*, i8** %7
%41 = call i64 @strcmp(i8* %39, i8* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %49
43: ; preds = %38
%44 = load i32, i32* %8
%45 = icmp sgt i32 %44, 2
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i8*, i8** %7
%48 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %46, %43, %38, %33
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%15s \00"
define void @compare_and_print(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = tail call i64 @strcmp(i8* %0, i8* %1)
%7 = icmp ne i64 %6, 0
%8 = icmp sgt i32 %3, 1
%9 = and i1 %8, %7
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = tail call i64 @strcmp(i8* %0, i8* %2)
%12 = icmp ne i64 %11, 0
%13 = icmp sgt i32 %3, 2
%14 = and i1 %13, %12
br i1 %14, label %15, label %18
15: ; preds = %10, %4
%16 = phi i8* [ %1, %4 ], [ %2, %10 ]
%17 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %10
%19 = tail call i64 @strcmp(i8* %0, i8* %2)
%20 = icmp eq i64 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %18
%22 = tail call i64 @strcmp(i8* %1, i8* %2)
%23 = icmp ne i64 %22, 0
%24 = icmp sgt i32 %3, 2
%25 = and i1 %24, %23
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %28
28: ; preds = %26, %21, %18
ret void
}