#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;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ asprintf(char **, char *, char *, char *);
char *basename(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int get_param(char *phy, char *stat) {
  char *filename = NULL;
  FILE *f = NULL;
  phy = basename(phy);
  stat = basename(stat);
  if (asprintf(&filename, "/sys/kernel/debug/ieee80211/%s/statistics/%s", phy,
               stat) > 0)
    f = fopen(filename, "r");
  if (f != NULL) {
    char temp[256];
    while (fgets(temp, 256, f) != NULL)
      printf("%s", temp);
    fclose(f);
  } else {
    perror("");
    return EXIT_FAILURE;
  }
  free(filename);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<get_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <basename@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <basename@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1080 <asprintf@plt>
cmp    $0x0,%rax
jle    11f3 <get_param+0x73>
mov    -0x20(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1248 <get_param+0xc8>
jmp    1203 <get_param+0x83>
lea    -0x130(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x100,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     123a <get_param+0xba>
lea    -0x130(%rbp),%rsi
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
jmp    1203 <get_param+0x83>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1265 <get_param+0xe5>
lea    0xddf(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    127a <get_param+0xfa>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_param>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %rsi,%rbx
movq   $0x0,0x8(%rsp)
call   1070 <basename@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <basename@plt>
lea    0xe51(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    %r14,%rdx
mov    %rax,%rcx
call   1080 <asprintf@plt>
test   %rax,%rax
jle    1258 <get_param+0xd8>
mov    0x8(%rsp),%rdi
lea    0xe59(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1258 <get_param+0xd8>
mov    %rax,%r15
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1230 <get_param+0xb0>
lea    0xe2b(%rip),%r14
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1210 <get_param+0x90>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdcf(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d75(%rip),%rax
jmp    1249 <get_param+0xc9>

LLVM IR (-O0):
@.str = [45 x i8] c"/sys/kernel/debug/ieee80211/%s/statistics/%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [1 x i8] zeroinitializer
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @get_param(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [256 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %6
store i32* null, i32** %7
%9 = load i8*, i8** %4
%10 = call i8* @basename(i8* %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %5
%12 = call i8* @basename(i8* %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %4
%14 = load i8*, i8** %5
%15 = call i64 @asprintf(i8** %6, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14)
%16 = icmp sgt i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8*, i8** %6
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %7
br label %20
20: ; preds = %17, %2
%21 = load i32*, i32** %7
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %35
23: ; preds = %20
br label %24
24: ; preds = %29, %23
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%26 = load i32*, i32** %7
%27 = call i32* @fgets(i8* %25, i32 256, i32* %26)
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %24
32: ; preds = %24
%33 = load i32*, i32** %7
%34 = call i32 @fclose(i32* %33)
br label %38
35: ; preds = %20
%36 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
store i32 %37, i32* %3
br label %42
38: ; preds = %32
%39 = load i8*, i8** %6
%40 = call i32 @free(i8* %39)
%41 = load i32, i32* @EXIT_SUCCESS
store i32 %41, i32* %3
br label %42
42: ; preds = %38, %35
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [45 x i8] c"/sys/kernel/debug/ieee80211/%s/statistics/%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [1 x i8] zeroinitializer
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @get_param(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca [256 x i8]
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = tail call i8* @basename(i8* %0)
%7 = tail call i8* @basename(i8* %1)
%8 = call i64 @asprintf(i8** %3, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %7)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %26, label %14
14: ; preds = %10
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%16 = call i32* @fgets(i8* %15, i32 256, i32* %12)
%17 = icmp eq i32* %16, null
br i1 %17, label %22, label %18
18: ; preds = %14, %18
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%20 = call i32* @fgets(i8* %15, i32 256, i32* %12)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %18
22: ; preds = %18, %14
%23 = call i32 @fclose(i32* %12)
%24 = load i8*, i8** %3
%25 = call i32 @free(i8* %24)
br label %28
26: ; preds = %2, %10
%27 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %22, %26
%29 = phi i32* [ @EXIT_SUCCESS, %22 ], [ @EXIT_FAILURE, %26 ]
%30 = load i32, i32* %29
ret i32 %30
}