#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char *, char *);
void set_param(char *ppath, int ival, char *sval) {
  FILE *fd;
  fd = fopen(ppath, "w");
  if (fd) {
    if (ival != -2)
      fprintf(fd, "%d", ival);
    else
      fprintf(fd, "%s", sval);
    fclose(fd);
  } else {
    printf("%s::error::parameter not available [%s]\n",
           "fujitsu_usb_touchscreen", ppath);
  }
}


x86 assembly (clang, -O0):
<set_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ba <set_param+0x7a>
cmpl   $0xfffffffe,-0xc(%rbp)
je     1196 <set_param+0x56>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    11ac <set_param+0x6c>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11d1 <set_param+0x91>
mov    -0x8(%rbp),%rdx
lea    0xe43(%rip),%rdi
lea    0xe65(%rip),%rsi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_param>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbp
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1187 <set_param+0x37>
mov    %rax,%rbx
cmp    $0xfffffffe,%r15d
jne    11a7 <set_param+0x57>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
jmp    11bb <set_param+0x6b>
lea    0xe77(%rip),%rdi
lea    0xe99(%rip),%rsi
mov    %rbp,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [41 x i8] c"%s::error::parameter not available [%s]\0A\00"
@.str.4 = [24 x i8] c"fujitsu_usb_touchscreen\00"
define void @set_param(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %26
12: ; preds = %3
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, -2
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32*, i32** %7
%17 = load i32, i32* %5
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %23
19: ; preds = %12
%20 = load i32*, i32** %7
%21 = load i8*, i8** %6
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %15
%24 = load i32*, i32** %7
%25 = call i32 @fclose(i32* %24)
br label %29
26: ; preds = %3
%27 = load i8*, i8** %4
%28 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %26, %23
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [41 x i8] c"%s::error::parameter not available [%s]\0A\00"
@.str.4 = [24 x i8] c"fujitsu_usb_touchscreen\00"
define void @set_param(i8* %0, i32 %1, i8* nocapture %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = icmp eq i32 %1, -2
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %12
10: ; preds = %6
%11 = tail call i32 @fputs(i8* %2, i32* %4)
br label %12
12: ; preds = %10, %8
%13 = tail call i32 @fclose(i32* %4)
br label %16
14: ; preds = %3
%15 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %16
16: ; preds = %14, %12
ret void
}