#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
char *strtok(char *, char *);
char *get_regex(char *ext_list) {
  char *param_regex = (char *)malloc(sizeof(char) * 64);
  char *p;
  unsigned int safe = 0;
  param_regex[0] = '\0';
  strcat(param_regex, "-regex '.*\\.\\(");
  p = strtok(ext_list, ":");
  strcat(param_regex, p);
  while (p = strtok(NULL, ":")) {
    strcat(param_regex, "\\|");
    strcat(param_regex, p);
    safe++;
    if (safe == 20)
      break;
  }
  strcat(param_regex, "\\)'");
  return param_regex;
}


x86 assembly (clang, -O0):
<get_regex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x40,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe7b(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11e1 <get_regex+0xb1>
mov    -0x10(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jne    11dc <get_regex+0xac>
jmp    11e1 <get_regex+0xb1>
jmp    1189 <get_regex+0x59>
mov    -0x10(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_regex>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
mov    $0x40,%edi
call   1030 <malloc@plt>
mov    %rax,%r12
movb   $0x0,(%rax)
lea    0xeae(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcat@plt>
lea    0xeae(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strtok@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1050 <strcat@plt>
mov    $0x14,%ebp
lea    0xe8e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     11bd <get_regex+0x8d>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
add    $0xffffffff,%ebp
jne    1190 <get_regex+0x60>
lea    0xe50(%rip),%rsi
mov    %r12,%rdi
call   1050 <strcat@plt>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"-regex '.*\\.\\(\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [3 x i8] c"\\|\00"
@.str.3 = [4 x i8] c"\\)'\00"
define i8* @get_regex(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i64 @malloc(i32 64)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %3
store i32 0, i32* %5
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
store i8 0, i8* %9
%10 = load i8*, i8** %3
%11 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %2
%13 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %4
%14 = load i8*, i8** %3
%15 = load i8*, i8** %4
%16 = call i32 @strcat(i8* %14, i8* %15)
br label %17
17: ; preds = %31, %1
%18 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %18, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = load i8*, i8** %3
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = load i8*, i8** %3
%24 = load i8*, i8** %4
%25 = call i32 @strcat(i8* %23, i8* %24)
%26 = load i32, i32* %5
%27 = add i32 %26, 1
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 20
br i1 %29, label %30, label %31
30: ; preds = %20
br label %32
31: ; preds = %20
br label %17
32: ; preds = %30, %17
%33 = load i8*, i8** %3
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
@.str = [15 x i8] c"-regex '.*\\.\\(\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [3 x i8] c"\\|\00"
@.str.3 = [4 x i8] c"\\)'\00"
define i8* @get_regex(i8* %0) {
%2 = tail call i64 @malloc(i32 64)
%3 = inttoptr i64 %2 to i8*
store i8 0, i8* %3
%4 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @strcat(i8* %3, i8* %5)
br label %7
7: ; preds = %11, %1
%8 = phi i32 [ 0, %1 ], [ %14, %11 ]
%9 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @strcat(i8* %3, i8* %9)
%14 = add nuw nsw i32 %8, 1
%15 = icmp eq i32 %14, 20
br i1 %15, label %16, label %7
16: ; preds = %11, %7
%17 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret i8* %3
}