#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*/ http_parse_block(char *, char const *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *http_URI(char *buffer, const char *request) {
  http_parse_block(buffer, request, 2);
  if (buffer[strlen(buffer) - 1] == '/') {
    strcpy(buffer + strlen(buffer), "index.html");
  }
  return buffer;
}


x86 assembly (clang, -O0):
<http_URI>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1050 <http_parse_block@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11a2 <http_URI+0x72>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
cltq
add    %rax,%rdi
lea    0xe63(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_URI>:
push   %rbx
mov    %rdi,%rbx
mov    $0x2,%edx
call   1050 <http_parse_block@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    1169 <http_URI+0x39>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
lea    0xe9c(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"index.html\00"
define i8* @http_URI(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = load i8*, i8** %4
%7 = call i32 @http_parse_block(i8* %5, i8* %6, i32 2)
%8 = load i8*, i8** %3
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %8, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 47
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = load i8*, i8** %3
%19 = load i8*, i8** %3
%20 = call i32 @strlen(i8* %19)
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %17, %2
%25 = load i8*, i8** %3
ret i8* %25
}

LLVM IR (-O2):
@.str = [11 x i8] c"index.html\00"
define i8* @http_URI(i8* returned %0, i8* %1) {
%3 = tail call i32 @http_parse_block(i8* %0, i8* %1, i32 2)
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, -1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 47
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = tail call i32 @strlen(i8* %0)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = tail call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %10, %2
ret i8* %0
}