#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*/ WTMP_FILE;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
char *strrchr(char *, char);
char *getbtmp() {
  static char btmp[128];
  char *p;
  strcpy(btmp, WTMP_FILE);
  if ((p = strrchr(btmp, '/')) == NULL)
    p = btmp;
  else
    p++;
  *p = 0;
  strcat(btmp, "btmp");
  return btmp;
}


x86 assembly (clang, -O0):
<getbtmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
lea    0x2f08(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2efc(%rip),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    117c <getbtmp+0x4c>
lea    0x2edd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1188 <getbtmp+0x58>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2eba(%rip),%rdi
lea    0xe63(%rip),%rsi
call   1050 <strcat@plt>
lea    0x2ea7(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getbtmp>:
push   %rbx
mov    0x2ea8(%rip),%rax
mov    (%rax),%esi
lea    0x2f0f(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
cmove  %rbx,%rcx
movb   $0x0,(%rcx)
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@getbtmp.btmp = internal global [128 x i8] zeroinitializer
@WTMP_FILE = global i32 0
@.str = [5 x i8] c"btmp\00"
define i8* @getbtmp() {
%1 = alloca i8*
%2 = load i32, i32* @WTMP_FILE
%3 = call i32 @strcpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getbtmp.btmp, i64 0, i64 0), i32 %2)
%4 = call i8* @strrchr(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getbtmp.btmp, i64 0, i64 0), i8 signext 47)
store i8* %4, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %0
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getbtmp.btmp, i64 0, i64 0), i8** %1
br label %10
7: ; preds = %0
%8 = load i8*, i8** %1
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %1
br label %10
10: ; preds = %7, %6
%11 = load i8*, i8** %1
store i8 0, i8* %11
%12 = call i32 @strcat(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getbtmp.btmp, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getbtmp.btmp, i64 0, i64 0)
}

LLVM IR (-O2):
@getbtmp.btmp = internal global [128 x i8] zeroinitializer
@WTMP_FILE = global i32 0
@.str = [5 x i8] c"btmp\00"
define i8* @getbtmp() {
%1 = load i32, i32* @WTMP_FILE
%2 = tail call i32 @strcpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getbtmp.btmp, i64 0, i64 0), i32 %1)
%3 = tail call i8* @strrchr(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @getbtmp.btmp, i64 0, i64 0), i8 signext 47)
%4 = icmp eq i8* %3, null
%5 = getelementptr inbounds i8, i8* %3, i64 1
%6 = select i1 %4, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getbtmp.btmp, i64 0, i64 0), i8* %5
store i8 0, i8* %6
%7 = tail call i32 @strcat(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getbtmp.btmp, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getbtmp.btmp, i64 0, i64 0)
}