#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*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(void const *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strlen(char *);
void genVersionFile(const void *buf, int len) {
  FILE *ppFile = NULL;
  char snBuf[1024];
  snprintf(
      snBuf, 1024,
      "Licensed by SoundAI Inc.\nPlease visit soundai.com \n\nLicensed to:%s\n",
      "QIHU360");
  if (access("/data", F_OK) == 0) {
    if (access("/data/sai_license.dat", F_OK)) {
      ppFile = fopen("/data/sai_license.dat", "wb");
      if (ppFile) {
        fwrite(snBuf, strlen(snBuf), 1, ppFile);
        fwrite(buf, len, 1, ppFile);
        fclose(ppFile);
      }
    }
  }
  if (access("/tmp", F_OK) == 0) {
    if (access("/tmp/sai_license.dat", F_OK)) {
      ppFile = fopen("/tmp/sai_license.dat", "wb");
      if (ppFile) {
        fwrite(snBuf, strlen(snBuf), 1, ppFile);
        fwrite(buf, len, 1, ppFile);
        fclose(ppFile);
      }
    }
  }
}


x86 assembly (clang, -O0):
<genVersionFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    $0x400,%esi
lea    0xe73(%rip),%rdx
lea    0xeb0(%rip),%rcx
call   1050 <snprintf@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
lea    0xea3(%rip),%rdi
call   1060 <access@plt>
cmp    $0x0,%rax
jne    1252 <genVersionFile+0xf2>
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
lea    0xe8a(%rip),%rdi
call   1060 <access@plt>
cmp    $0x0,%rax
je     124d <genVersionFile+0xed>
lea    0xe74(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1248 <genVersionFile+0xe8>
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x428(%rbp),%rdi
mov    %eax,%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    124d <genVersionFile+0xed>
jmp    1252 <genVersionFile+0xf2>
mov    0x2d7f(%rip),%rax
mov    (%rax),%esi
lea    0xe09(%rip),%rdi
call   1060 <access@plt>
cmp    $0x0,%rax
jne    130b <genVersionFile+0x1ab>
mov    0x2d60(%rip),%rax
mov    (%rax),%esi
lea    0xdef(%rip),%rdi
call   1060 <access@plt>
cmp    $0x0,%rax
je     1306 <genVersionFile+0x1a6>
lea    0xdd9(%rip),%rdi
lea    0xdca(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1301 <genVersionFile+0x1a1>
lea    -0x420(%rbp),%rax
mov    %rax,-0x430(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x430(%rbp),%rdi
mov    %eax,%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1306 <genVersionFile+0x1a6>
jmp    130b <genVersionFile+0x1ab>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genVersionFile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %esi,%r14d
mov    %rdi,%r12
lea    0xe84(%rip),%rdx
lea    0xec1(%rip),%rcx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1050 <snprintf@plt>
mov    0x2e41(%rip),%rbx
mov    (%rbx),%esi
lea    0xeac(%rip),%rdi
call   1060 <access@plt>
test   %rax,%rax
jne    1210 <genVersionFile+0xb0>
mov    (%rbx),%esi
lea    0xe9f(%rip),%rdi
call   1060 <access@plt>
test   %rax,%rax
je     1210 <genVersionFile+0xb0>
lea    0xe8e(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1210 <genVersionFile+0xb0>
mov    %rax,%rbp
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1080 <fwrite@plt>
mov    %r12,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1080 <fwrite@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    (%rbx),%esi
lea    0xe52(%rip),%rdi
call   1060 <access@plt>
test   %rax,%rax
jne    1289 <genVersionFile+0x129>
mov    (%rbx),%esi
lea    0xe44(%rip),%rdi
call   1060 <access@plt>
test   %rax,%rax
je     1289 <genVersionFile+0x129>
lea    0xe33(%rip),%rdi
lea    0xe24(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1289 <genVersionFile+0x129>
mov    %rax,%rbp
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1080 <fwrite@plt>
mov    %r12,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1080 <fwrite@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [68 x i8] c"Licensed by SoundAI Inc.\0APlease visit soundai.com \0A\0ALicensed to:%s\0A\00"
@.str.1 = [8 x i8] c"QIHU360\00"
@.str.2 = [6 x i8] c"/data\00"
@F_OK = global i32 0
@.str.3 = [22 x i8] c"/data/sai_license.dat\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [5 x i8] c"/tmp\00"
@.str.6 = [21 x i8] c"/tmp/sai_license.dat\00"
define void @genVersionFile(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [1024 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32* null, i32** %5
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 1024, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @F_OK
%10 = call i64 @access(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %34
12: ; preds = %2
%13 = load i32, i32* @F_OK
%14 = call i64 @access(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %17, i32** %5
%18 = load i32*, i32** %5
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = load i32*, i32** %5
%25 = call i32 @fwrite(i8* %21, i32 %23, i32 1, i32* %24)
%26 = load i8*, i8** %3
%27 = load i32, i32* %4
%28 = load i32*, i32** %5
%29 = call i32 @fwrite(i8* %26, i32 %27, i32 1, i32* %28)
%30 = load i32*, i32** %5
%31 = call i32 @fclose(i32* %30)
br label %32
32: ; preds = %20, %16
br label %33
33: ; preds = %32, %12
br label %34
34: ; preds = %33, %2
%35 = load i32, i32* @F_OK
%36 = call i64 @access(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %60
38: ; preds = %34
%39 = load i32, i32* @F_OK
%40 = call i64 @access(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %59
42: ; preds = %38
%43 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %43, i32** %5
%44 = load i32*, i32** %5
%45 = icmp ne i32* %44, null
br i1 %45, label %46, label %58
46: ; preds = %42
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%49 = call i32 @strlen(i8* %48)
%50 = load i32*, i32** %5
%51 = call i32 @fwrite(i8* %47, i32 %49, i32 1, i32* %50)
%52 = load i8*, i8** %3
%53 = load i32, i32* %4
%54 = load i32*, i32** %5
%55 = call i32 @fwrite(i8* %52, i32 %53, i32 1, i32* %54)
%56 = load i32*, i32** %5
%57 = call i32 @fclose(i32* %56)
br label %58
58: ; preds = %46, %42
br label %59
59: ; preds = %58, %38
br label %60
60: ; preds = %59, %34
ret void
}

LLVM IR (-O2):
@.str = [68 x i8] c"Licensed by SoundAI Inc.\0APlease visit soundai.com \0A\0ALicensed to:%s\0A\00"
@.str.1 = [8 x i8] c"QIHU360\00"
@.str.2 = [6 x i8] c"/data\00"
@F_OK = global i32 0
@.str.3 = [22 x i8] c"/data/sai_license.dat\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [5 x i8] c"/tmp\00"
@.str.6 = [21 x i8] c"/tmp/sai_license.dat\00"
define void @genVersionFile(i8* nocapture %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @snprintf(i8* %4, i32 1024, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @F_OK
%7 = call i64 @access(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %2
%10 = load i32, i32* @F_OK
%11 = call i64 @access(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %9
%14 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = call i32 @strlen(i8* %4)
%18 = call i32 @fwrite(i8* %4, i32 %17, i32 1, i32* %14)
%19 = call i32 @fwrite(i8* %0, i32 %1, i32 1, i32* %14)
%20 = call i32 @fclose(i32* %14)
br label %21
21: ; preds = %9, %16, %13, %2
%22 = load i32, i32* @F_OK
%23 = call i64 @access(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load i32, i32* @F_OK
%27 = call i64 @access(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %25
%30 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = call i32 @strlen(i8* %4)
%34 = call i32 @fwrite(i8* %4, i32 %33, i32 1, i32* %30)
%35 = call i32 @fwrite(i8* %0, i32 %1, i32 1, i32* %30)
%36 = call i32 @fclose(i32* %30)
br label %37
37: ; preds = %25, %32, %29, %21
ret void
}