#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*/ strcmp(char *, char *);
int strlen(char *);
int switch_little_big_f(char s[]) {
  int n;
  n = strlen(s);
  if (!strcmp(&(s[n - 2]), ".f")) {
    s[n - 1] = 'F';
  } else if (!strcmp(&(s[n - 2]), ".F")) {
    s[n - 1] = 'f';
  }
  return (0);
}


x86 assembly (clang, -O0):
<switch_little_big_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
cltq
add    %rax,%rdi
lea    0xeb2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1172 <switch_little_big_f+0x52>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x46,(%rax,%rcx,1)
jmp    11ac <switch_little_big_f+0x8c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
cltq
add    %rax,%rdi
lea    0xe7b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a7 <switch_little_big_f+0x87>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x66,(%rax,%rcx,1)
jmp    11ac <switch_little_big_f+0x8c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<switch_little_big_f>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
movslq %eax,%r15
lea    (%r15,%r14,1),%rbx
add    $0xfffffffffffffffe,%rbx
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1162 <switch_little_big_f+0x42>
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1169 <switch_little_big_f+0x49>
mov    $0x66,%al
jmp    1164 <switch_little_big_f+0x44>
mov    $0x46,%al
mov    %al,-0x1(%r15,%r14,1)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c".f\00"
@.str.1 = [3 x i8] c".F\00"
define i32 @switch_little_big_f(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
store i32 %5, i32* %3
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sub nsw i32 %7, 2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %6, i64 %9
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %1
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
store i8 70, i8* %18
br label %34
19: ; preds = %1
%20 = load i8*, i8** %2
%21 = load i32, i32* %3
%22 = sub nsw i32 %21, 2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %19
%28 = load i8*, i8** %2
%29 = load i32, i32* %3
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
store i8 102, i8* %32
br label %33
33: ; preds = %27, %19
br label %34
34: ; preds = %33, %13
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c".f\00"
@.str.1 = [3 x i8] c".F\00"
define i32 @switch_little_big_f(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -2
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %8, %1
%12 = phi i8 [ 70, %1 ], [ 102, %8 ]
%13 = add nsw i32 %2, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 %12, i8* %15
br label %16
16: ; preds = %11, %8
ret i32 0
}