#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 */
char *s_malloc_(int, char *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
char *file_changeExt(const char *fname, const char *ext) {
  char *p, *buf, *last;
  buf = s_malloc_(strlen(fname) + strlen(ext),
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/kujirahand/sakuramml-c/"
                  "refs/heads/master/src/s_lib.c",
                  135);
  strcpy(buf, fname);
  last = buf + strlen(buf);
  p = buf;
  while (*p != '\0') {
    if (*p == '.')
      last = p;
    p++;
  }
  strcpy(last, ext);
  return buf;
}


x86 assembly (clang, -O0):
<file_changeExt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x34(%rbp),%edi
add    %eax,%edi
lea    0xe9f(%rip),%rsi
mov    $0x87,%edx
call   1050 <s_malloc_@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11de <file_changeExt+0xae>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11cd <file_changeExt+0x9d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11a5 <file_changeExt+0x75>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_changeExt>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %eax,%ebx
lea    0xead(%rip),%rsi
mov    %ebx,%edi
mov    $0x87,%edx
call   1050 <s_malloc_@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
mov    %rbx,%rax
jmp    1187 <file_changeExt+0x57>
mov    %rax,%rdi
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x2e,%cl
je     1180 <file_changeExt+0x50>
test   %cl,%cl
jne    1183 <file_changeExt+0x53>
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kujirahand/sakuramml-c/refs/heads/master/src/s_lib.c\00"
define i8* @file_changeExt(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = add nsw i32 %9, %11
%13 = call i8* @s_malloc_(i32 %12, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 135)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = load i8*, i8** %3
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = load i8*, i8** %6
%18 = load i8*, i8** %6
%19 = call i32 @strlen(i8* %18)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
store i8* %21, i8** %7
%22 = load i8*, i8** %6
store i8* %22, i8** %5
br label %23
23: ; preds = %35, %2
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %23
%29 = load i8*, i8** %5
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 46
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = load i8*, i8** %5
store i8* %34, i8** %7
br label %35
35: ; preds = %33, %28
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %5
br label %23
38: ; preds = %23
%39 = load i8*, i8** %7
%40 = load i8*, i8** %4
%41 = call i32 @strcpy(i8* %39, i8* %40)
%42 = load i8*, i8** %6
ret i8* %42
}

LLVM IR (-O2):
@.str = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kujirahand/sakuramml-c/refs/heads/master/src/s_lib.c\00"
define i8* @file_changeExt(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = add nsw i32 %4, %3
%6 = tail call i8* @s_malloc_(i32 %5, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 135)
%7 = tail call i32 @strcpy(i8* %6, i8* %0)
%8 = tail call i32 @strlen(i8* %6)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %6, i64 %9
br label %11
11: ; preds = %16, %2
%12 = phi i8* [ %6, %2 ], [ %18, %16 ]
%13 = phi i8* [ %10, %2 ], [ %17, %16 ]
%14 = load i8, i8* %12
switch i8 %14, label %16 [
i8 0, label %19
i8 46, label %15
]
15: ; preds = %11
br label %16
16: ; preds = %11, %15
%17 = phi i8* [ %12, %15 ], [ %13, %11 ]
%18 = getelementptr inbounds i8, i8* %12, i64 1
br label %11
19: ; preds = %11
%20 = tail call i32 @strcpy(i8* %13, i8* %1)
ret i8* %6
}