#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 */
int /*<<< orphan*/ strcpy(char *, char *);
void setAllowedFiles(char *str, char arr[10][1024]) {
  char buf_tmp[1024];
  int i = 0, j = 0, a = 0;
  while (str[i] != '\0') {
    if (str[i] == ';') {
      buf_tmp[j] = '\0';
      strcpy(arr[a++], buf_tmp);
      j = 0;
    } else {
      buf_tmp[j++] = str[i];
    }
    ++i;
  }
  buf_tmp[j] = '\0';
  strcpy(arr[a], buf_tmp);
}


x86 assembly (clang, -O0):
<setAllowedFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x414(%rbp)
movl   $0x0,-0x418(%rbp)
movl   $0x0,-0x41c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x414(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11f5 <setAllowedFiles+0xe5>
mov    -0x8(%rbp),%rax
movslq -0x414(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3b,%eax
jne    11b9 <setAllowedFiles+0xa9>
movslq -0x418(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
mov    -0x41c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x41c(%rbp)
cltq
shl    $0xa,%rax
add    %rax,%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x418(%rbp)
jmp    11e1 <setAllowedFiles+0xd1>
mov    -0x8(%rbp),%rax
movslq -0x414(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x418(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x418(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1141 <setAllowedFiles+0x31>
movslq -0x418(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
movslq -0x41c(%rbp),%rax
shl    $0xa,%rax
add    %rax,%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setAllowedFiles>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
mov    %rsp,%r15
xor    %ebp,%ebp
jmp    1151 <setAllowedFiles+0x41>
nopl   0x0(%rax)
cltq
movb   $0x0,(%rsp,%rax,1)
movslq %ebp,%rdi
add    $0x1,%ebp
shl    $0xa,%rdi
add    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
add    $0x1,%rbx
xor    %eax,%eax
movzbl (%rbx),%ecx
cmp    $0x3b,%cl
je     1130 <setAllowedFiles+0x20>
movslq %eax,%rdx
test   %cl,%cl
je     116c <setAllowedFiles+0x5c>
add    $0x1,%eax
mov    %cl,(%rsp,%rdx,1)
add    $0x1,%rbx
jmp    1151 <setAllowedFiles+0x41>
movb   $0x0,(%rsp,%rdx,1)
movslq %ebp,%rax
shl    $0xa,%rax
add    %rax,%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @setAllowedFiles(i8* %0, [1024 x i8]* %1) {
%3 = alloca i8*
%4 = alloca [1024 x i8]*
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store [1024 x i8]* %1, [1024 x i8]** %4
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %47, %2
%10 = load i8*, i8** %3
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %50
17: ; preds = %9
%18 = load i8*, i8** %3
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 59
br i1 %24, label %25, label %37
25: ; preds = %17
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %27
store i8 0, i8* %28
%29 = load [1024 x i8]*, [1024 x i8]** %4
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %29, i64 %32
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %33, i64 0, i64 0
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%36 = call i32 @strcpy(i8* %34, i8* %35)
store i32 0, i32* %7
br label %47
37: ; preds = %17
%38 = load i8*, i8** %3
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %45
store i8 %42, i8* %46
br label %47
47: ; preds = %37, %25
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %9
50: ; preds = %9
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %52
store i8 0, i8* %53
%54 = load [1024 x i8]*, [1024 x i8]** %4
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %54, i64 %56
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %57, i64 0, i64 0
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%60 = call i32 @strcpy(i8* %58, i8* %59)
ret void
}

LLVM IR (-O2):
define void @setAllowedFiles(i8* nocapture %0, [1024 x i8]* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %22, %2
%6 = phi i64 [ %25, %22 ], [ 0, %2 ]
%7 = phi i32 [ %23, %22 ], [ 0, %2 ]
%8 = phi i32 [ %24, %22 ], [ 0, %2 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %6
%10 = load i8, i8* %9
switch i8 %10, label %18 [
i8 0, label %26
i8 59, label %11
]
11: ; preds = %5
%12 = sext i32 %7 to i64
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %12
store i8 0, i8* %13
%14 = add nsw i32 %8, 1
%15 = sext i32 %8 to i64
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 %15, i64 0
%17 = call i32 @strcpy(i8* %16, i8* %4)
br label %22
18: ; preds = %5
%19 = add nsw i32 %7, 1
%20 = sext i32 %7 to i64
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %20
store i8 %10, i8* %21
br label %22
22: ; preds = %18, %11
%23 = phi i32 [ 0, %11 ], [ %19, %18 ]
%24 = phi i32 [ %14, %11 ], [ %8, %18 ]
%25 = add nuw i64 %6, 1
br label %5
26: ; preds = %5
%27 = sext i32 %7 to i64
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %27
store i8 0, i8* %28
%29 = sext i32 %8 to i64
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 %29, i64 0
%31 = call i32 @strcpy(i8* %30, i8* %4)
ret void
}