#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 *get_wifi_firmware();
char *get_wifi_nvram();
int /*<<< orphan*/ sprintf(char *, char *, char *, char const *);
int rkwifi_set_firmware(char *fw, char *nvram) {
  const char *ff = get_wifi_firmware();
  const char *nv = get_wifi_nvram();
  if (ff && nv) {
    sprintf(fw, "%s%s", "/system/etc/firmware/", ff);
    sprintf(nvram, "%s%s", "/system/etc/firmware/", nv);
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<rkwifi_set_firmware>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1050 <get_wifi_firmware@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <get_wifi_nvram@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ae <rkwifi_set_firmware+0x7e>
cmpq   $0x0,-0x28(%rbp)
je     11ae <rkwifi_set_firmware+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rcx
lea    0xe85(%rip),%rsi
lea    0xe83(%rip),%rdx
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rcx
lea    0xe6a(%rip),%rsi
lea    0xe68(%rip),%rdx
call   1040 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <rkwifi_set_firmware+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rkwifi_set_firmware>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1050 <get_wifi_firmware@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <get_wifi_nvram@plt>
test   %rbx,%rbx
je     118f <rkwifi_set_firmware+0x5f>
mov    %rax,%r12
test   %rax,%rax
je     118f <rkwifi_set_firmware+0x5f>
lea    0xe9a(%rip),%r13
lea    0xe98(%rip),%rbp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1040 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1040 <sprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [22 x i8] c"/system/etc/firmware/\00"
define i32 @rkwifi_set_firmware(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = call i8* (...) @get_wifi_firmware()
store i8* %8, i8** %6
%9 = call i8* (...) @get_wifi_nvram()
store i8* %9, i8** %7
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %22
12: ; preds = %2
%13 = load i8*, i8** %7
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i8*, i8** %4
%17 = load i8*, i8** %6
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %5
%20 = load i8*, i8** %7
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i32 0, i32* %3
br label %23
22: ; preds = %12, %2
store i32 0, i32* %3
br label %23
23: ; preds = %22, %15
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [22 x i8] c"/system/etc/firmware/\00"
define i32 @rkwifi_set_firmware(i8* nocapture writeonly %0, i8* nocapture writeonly %1) {
%3 = tail call i8* (...) @get_wifi_firmware()
%4 = tail call i8* (...) @get_wifi_nvram()
%5 = icmp ne i8* %3, null
%6 = icmp ne i8* %4, null
%7 = select i1 %5, i1 %6, i1 false
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%10 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %11
11: ; preds = %2, %8
ret i32 0
}