#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*/ file_suffix;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
int test_if_download_temp_file(char *filename) {
  char file_suffix[9];
  char *temp_suffix = ".asus.td";
  memset(file_suffix, 0, sizeof(file_suffix));
  char *p = filename;
  if (strstr(filename, temp_suffix)) {
    strcpy(file_suffix, p + (strlen(filename) - strlen(temp_suffix)));
    if (!strcmp(file_suffix, temp_suffix))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_if_download_temp_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe9d(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x19(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11fb <test_if_download_temp_file+0xab>
lea    -0x19(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdi
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
sub    %ecx,%eax
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x19(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11f6 <test_if_download_temp_file+0xa6>
movl   $0x1,-0x4(%rbp)
jmp    1202 <test_if_download_temp_file+0xb2>
jmp    11fb <test_if_download_temp_file+0xab>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_if_download_temp_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x7(%rsp),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0x9,%edx
call   1050 <memset@plt>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     11ba <test_if_download_temp_file+0x7a>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xe7c(%rip),%rdi
call   1040 <strlen@plt>
sub    %eax,%ebp
movslq %ebp,%rsi
add    %rbx,%rsi
lea    0x7(%rsp),%rdi
call   1030 <strcpy@plt>
movabs $0x64742e737573612e,%rax
2e 74 64
xor    0x7(%rsp),%rax
movzbl 0xf(%rsp),%ecx
or     %rax,%rcx
jne    11ba <test_if_download_temp_file+0x7a>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c".asus.td\00"
define i32 @test_if_download_temp_file(i8* %0) {
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 9)
%5 = call i64 @strstr(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %1
%8 = call i32 @strlen(i8* %0)
%9 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = sub nsw i32 %8, %9
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = call i32 @strcpy(i8* %3, i8* %12)
%14 = call i32 @bcmp(i8* dereferenceable(9) %3, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 9)
%15 = icmp eq i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %7, %1
br label %17
17: ; preds = %7, %16
%18 = phi i32 [ 0, %16 ], [ 1, %7 ]
ret i32 %18
}