#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 *, ...);
int /*<<< orphan*/ strncpy(char *, char *, int);
char toupper(char);
int print_palindrome(const char *word, char *article, long pos, long total) {
  char prefix[3];
  if (pos == 0) {
    article[0] = toupper(article[0]);
    prefix[0] = '\0';
  } else if (pos == total - 1) {
    strncpy(prefix, " -", 3);
  } else {
    strncpy(prefix, ", ", 3);
  }
  printf("%s", prefix);
  if (pos != total - 1)
    printf("%s", article);
  printf(" %s", word);
  if (pos == total - 1)
    printf("!");
  return 0;
}


x86 assembly (clang, -O0):
<print_palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1170 <print_palindrome+0x40>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <toupper@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movb   $0x0,-0x23(%rbp)
jmp    11b9 <print_palindrome+0x89>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jne    119f <print_palindrome+0x6f>
lea    -0x23(%rbp),%rdi
lea    0xe70(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
jmp    11b4 <print_palindrome+0x84>
lea    -0x23(%rbp),%rdi
lea    0xe59(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
jmp    11b9 <print_palindrome+0x89>
lea    -0x23(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
je     11f2 <print_palindrome+0xc2>
mov    -0x10(%rbp),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jne    1227 <print_palindrome+0xf7>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_palindrome>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r14
test   %rdx,%rdx
je     116b <print_palindrome+0x2b>
add    $0xffffffffffffffff,%rbx
cmp    %r12,%rbx
jne    1182 <print_palindrome+0x42>
lea    0xe97(%rip),%rsi
jmp    1189 <print_palindrome+0x49>
movsbl (%r15),%edi
call   1050 <toupper@plt>
mov    %al,(%r15)
movb   $0x0,0x5(%rsp)
add    $0xffffffffffffffff,%rbx
jmp    1198 <print_palindrome+0x58>
lea    0xe7a(%rip),%rsi
lea    0x5(%rsp),%rdi
mov    $0x3,%edx
call   1040 <strncpy@plt>
lea    0xe68(%rip),%rdi
lea    0x5(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    %r12,%rbx
jne    11cd <print_palindrome+0x8d>
lea    0xe4f(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x21,%edi
call   1030 <putchar@plt>
jmp    11ef <print_palindrome+0xaf>
lea    0xe33(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe21(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c" -\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [4 x i8] c" %s\00"
define i32 @print_palindrome(i8* %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca [3 x i8]
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%7 = icmp eq i64 %2, 0
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = load i8, i8* %1
%10 = tail call signext i8 @toupper(i8 signext %9)
store i8 %10, i8* %1
store i8 0, i8* %6
%11 = add nsw i64 %3, -1
br label %19
12: ; preds = %4
%13 = add nsw i64 %3, -1
%14 = icmp eq i64 %13, %2
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @strncpy(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 3)
br label %19
17: ; preds = %12
%18 = call i32 @strncpy(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 3)
br label %19
19: ; preds = %15, %17, %8
%20 = phi i64 [ %13, %15 ], [ %13, %17 ], [ %11, %8 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%22 = icmp eq i64 %20, %2
br i1 %22, label %26, label %23
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %29
26: ; preds = %19
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%28 = call i32 @putchar(i32 33)
br label %29
29: ; preds = %23, %26
ret i32 0
}