#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ mkdir(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
void touchFile(int groupID, int sensorID) {
  FILE *f = NULL;
  char *filename, *dirname;
  if (NULL == (filename = (char *)malloc(sizeof(char *)))) {
    exit(1);
  }
  if (NULL == (dirname = (char *)malloc(sizeof(char *)))) {
    exit(1);
  }
  sprintf(dirname, "%i", groupID);
  sprintf(filename, "%i/%i.txt", groupID, sensorID);
  mkdir(dirname);
  f = fopen(filename, "w");
  fclose(f);
  free(filename);
  free(dirname);
}


x86 assembly (clang, -O0):
<touchFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11ac <touchFile+0x3c>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11d2 <touchFile+0x62>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe20(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <mkdir@plt>
mov    -0x18(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<touchFile>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%ebp
mov    $0x8,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1202 <touchFile+0x92>
mov    %rax,%r14
mov    $0x8,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1202 <touchFile+0x92>
mov    %rax,%rbx
lea    0xe59(%rip),%rsi
mov    %rax,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xe49(%rip),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <mkdir@plt>
lea    0xe35(%rip),%rsi
mov    %r14,%rdi
call   1070 <fopen@plt>
mov    %rax,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [10 x i8] c"%i/%i.txt\00"
@.str.2 = [2 x i8] c"w\00"
define void @touchFile(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32* null, i32** %5
%8 = call i64 @malloc(i32 8)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %6
%10 = icmp eq i8* null, %9
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = call i64 @malloc(i32 8)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %7
%16 = icmp eq i8* null, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %13
%20 = load i8*, i8** %7
%21 = load i32, i32* %3
%22 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i8*, i8** %6
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i8*, i8** %7
%28 = call i32 @mkdir(i8* %27)
%29 = load i8*, i8** %6
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %30, i32** %5
%31 = load i32*, i32** %5
%32 = call i32 @fclose(i32* %31)
%33 = load i8*, i8** %6
%34 = call i32 @free(i8* %33)
%35 = load i8*, i8** %7
%36 = call i32 @free(i8* %35)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.1 = [10 x i8] c"%i/%i.txt\00"
@.str.2 = [2 x i8] c"w\00"
define void @touchFile(i32 %0, i32 %1) {
%3 = tail call i64 @malloc(i32 8)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i64 @malloc(i32 8)
%10 = inttoptr i64 %9 to i8*
%11 = icmp eq i64 %9, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8
%15 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%16 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1)
%17 = tail call i32 @mkdir(i8* %10)
%18 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 @fclose(i32* %18)
%20 = tail call i32 @free(i8* %4)
%21 = tail call i32 @free(i8* %10)
ret void
}