#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ systemlog(int, char *);
int find_and_add_fp(char st[], char cmd[], char fp[]) {
  int activ = 0;
  int i = 0;
  char c[2];
  char tmpcmd[256];
  systemlog(4, "find_and_add_fp");
  c[0] = '/';
  c[1] = '\0';
  tmpcmd[0] = '\0';
  for (i = 0; i != strlen(cmd); i++) {
    if (cmd[i] == '$' && cmd[i + 1] == 'f') {
      activ |= 1;
      strcat(tmpcmd, fp);
      i += 2;
    }
    c[0] = cmd[i];
    strcat(tmpcmd, c);
  }
  strcpy(st, tmpcmd);
  return activ;
}


x86 assembly (clang, -O0):
<find_and_add_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    $0x4,%edi
lea    0xe8f(%rip),%rsi
call   1030 <systemlog@plt>
movb   $0x2f,-0x22(%rbp)
movb   $0x0,-0x21(%rbp)
movb   $0x0,-0x130(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x134(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x134(%rbp),%eax
cmp    %ecx,%eax
je     122b <find_and_add_fp+0xeb>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x24,%eax
jne    11ff <find_and_add_fp+0xbf>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x66,%eax
jne    11ff <find_and_add_fp+0xbf>
mov    -0x1c(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x22(%rbp)
lea    -0x130(%rbp),%rdi
lea    -0x22(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118c <find_and_add_fp+0x4c>
mov    -0x8(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x1c(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_and_add_fp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rdx,0x18(%rsp)
mov    %rsi,%rbx
mov    %rdi,0x10(%rsp)
lea    0xe9b(%rip),%rsi
mov    $0x4,%edi
call   1030 <systemlog@plt>
movw   $0x2f,0xe(%rsp)
movb   $0x0,0x20(%rsp)
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
je     11f6 <find_and_add_fp+0xb6>
xor    %r14d,%r14d
lea    0x20(%rsp),%rbp
lea    0xe(%rsp),%r13
xor    %r12d,%r12d
jmp    11c0 <find_and_add_fp+0x80>
nopl   0x0(%rax)
mov    %al,0xe(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
add    $0x1,%r14d
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    %eax,%r14d
je     11f9 <find_and_add_fp+0xb9>
movslq %r14d,%r15
movzbl (%rbx,%r15,1),%eax
cmp    $0x24,%al
jne    11a0 <find_and_add_fp+0x60>
mov    $0x24,%al
cmpb   $0x66,0x1(%r15,%rbx,1)
jne    11a0 <find_and_add_fp+0x60>
or     $0x1,%r12d
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
call   1060 <strcat@plt>
movzbl 0x2(%rbx,%r15,1),%eax
add    $0x2,%r15
mov    %r15d,%r14d
jmp    11a0 <find_and_add_fp+0x60>
xor    %r12d,%r12d
lea    0x20(%rsp),%rsi
mov    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
mov    %r12d,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"find_and_add_fp\00"
define i32 @find_and_add_fp(i8* %0, i8* %1, i8* %2) {
%4 = alloca [2 x i8]
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = tail call i32 @systemlog(i32 4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i8 47, i8* %6
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
store i8 0, i8* %9
store i8 0, i8* %7
%10 = call i32 @strlen(i8* %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %40, label %12
12: ; preds = %3, %32
%13 = phi i32 [ %37, %32 ], [ 0, %3 ]
%14 = phi i32 [ %34, %32 ], [ 0, %3 ]
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds i8, i8* %1, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 36
br i1 %18, label %19, label %32
19: ; preds = %12
%20 = add nsw i32 %13, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 102
br i1 %24, label %25, label %32
25: ; preds = %19
%26 = or i32 %14, 1
%27 = call i32 @strcat(i8* %7, i8* %2)
%28 = add nsw i32 %13, 2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %1, i64 %29
%31 = load i8, i8* %30
br label %32
32: ; preds = %25, %19, %12
%33 = phi i8 [ %31, %25 ], [ 36, %19 ], [ %17, %12 ]
%34 = phi i32 [ %26, %25 ], [ %14, %19 ], [ %14, %12 ]
%35 = phi i32 [ %28, %25 ], [ %13, %19 ], [ %13, %12 ]
store i8 %33, i8* %6
%36 = call i32 @strcat(i8* %7, i8* %6)
%37 = add nsw i32 %35, 1
%38 = call i32 @strlen(i8* %1)
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %12
40: ; preds = %32, %3
%41 = phi i32 [ 0, %3 ], [ %34, %32 ]
%42 = call i32 @strcpy(i8* %0, i8* %7)
ret i32 %41
}