#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 */
typedef int /*<<< orphan*/ int8_t;
typedef size_t int32_t;

/* Variables and functions */
int /*<<< orphan*/ strcat(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/ *, char *);
int32_t fixpath(char *inpath, int8_t *outpath) {
  int32_t n = 0;
  strcpy(outpath, inpath);
  while (inpath[n])
    n++;
  if (inpath[n - 1] != '/') {
    strcat(outpath, "/");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<fixpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1168 <fixpath+0x48>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1145 <fixpath+0x25>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     119e <fixpath+0x7e>
mov    -0x18(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1040 <strcat@plt>
movq   $0x1,-0x8(%rbp)
jmp    11a6 <fixpath+0x86>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixpath>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1140 <fixpath+0x20>
cmpb   $0x2f,-0x2(%rbx)
jne    1153 <fixpath+0x33>
xor    %eax,%eax
jmp    1167 <fixpath+0x47>
lea    0xea6(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i64 @fixpath(i8* %0, i32* %1) {
%3 = tail call i32 @strcpy(i32* %1, i8* %0)
br label %4
4: ; preds = %4, %2
%5 = phi i64 [ 0, %2 ], [ %9, %4 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
%9 = add i64 %5, 1
br i1 %8, label %10, label %4
10: ; preds = %4
%11 = add i64 %5, -1
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 47
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = tail call i32 @strcat(i32* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %10, %15
%18 = phi i64 [ 1, %15 ], [ 0, %10 ]
ret i64 %18
}