#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*/ free(char *);
char *iStrDupUntilNoCase(char **, char);
int /*<<< orphan*/ strcpy(char *, char const *);
int iupStrToStrStr(const char *str, char *str1, char *str2, char sep) {
  if (!str)
    return 0;
  if (((*str >= 'A' && *str <= 'Z') ? (*str - 'A') + 'a' : *str) == sep) {
    str++;
    str1[0] = 0;
    strcpy(str2, str);
    return 1;
  } else {
    char *p_str = iStrDupUntilNoCase((char **)&str, sep);
    if (!p_str) {
      strcpy(str1, str);
      str2[0] = 0;
      return 1;
    } else if (*str == 0) {
      strcpy(str1, p_str);
      free(p_str);
      str2[0] = 0;
      return 1;
    } else {
      strcpy(str1, p_str);
      strcpy(str2, str);
      free(p_str);
      return 2;
    }
  }
}


x86 assembly (clang, -O0):
<iupStrToStrStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %cl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %al,-0x21(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1160 <iupStrToStrStr+0x30>
movl   $0x0,-0x4(%rbp)
jmp    1279 <iupStrToStrStr+0x149>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jl     1195 <iupStrToStrStr+0x65>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jg     1195 <iupStrToStrStr+0x65>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
sub    $0x41,%eax
add    $0x61,%eax
mov    %eax,-0x34(%rbp)
jmp    119f <iupStrToStrStr+0x6f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
movsbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
jne    11da <iupStrToStrStr+0xaa>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    1279 <iupStrToStrStr+0x149>
lea    -0x10(%rbp),%rdi
movsbl -0x21(%rbp),%esi
call   1050 <iStrDupUntilNoCase@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1216 <iupStrToStrStr+0xe6>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1279 <iupStrToStrStr+0x149>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    124f <iupStrToStrStr+0x11f>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1279 <iupStrToStrStr+0x149>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iupStrToStrStr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %rdi,%rdi
je     1178 <iupStrToStrStr+0x48>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rax
movsbl (%rdi),%edx
lea    -0x41(%rdx),%esi
lea    0x20(%rdx),%edi
cmp    $0x1a,%sil
cmovae %edx,%edi
movsbl %cl,%esi
cmp    %esi,%edi
jne    117c <iupStrToStrStr+0x4c>
add    $0x1,%rax
mov    %rax,(%rsp)
movb   $0x0,(%rbx)
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
jmp    11d4 <iupStrToStrStr+0xa4>
xor    %eax,%eax
jmp    11d9 <iupStrToStrStr+0xa9>
mov    %rsp,%rdi
call   1050 <iStrDupUntilNoCase@plt>
mov    (%rsp),%rsi
test   %rax,%rax
je     11be <iupStrToStrStr+0x8e>
mov    %rax,%r15
mov    (%rsi),%bpl
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
test   %bpl,%bpl
je     11c8 <iupStrToStrStr+0x98>
mov    (%rsp),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    $0x2,%eax
jmp    11d9 <iupStrToStrStr+0xa9>
mov    %rbx,%rdi
call   1040 <strcpy@plt>
jmp    11d0 <iupStrToStrStr+0xa0>
mov    %r15,%rdi
call   1030 <free@plt>
movb   $0x0,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @iupStrToStrStr(i8* %0, i8* %1, i8* %2, i8 signext %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8 %3, i8* %9
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %4
store i32 0, i32* %5
br label %80
14: ; preds = %4
%15 = load i8*, i8** %6
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp sge i32 %17, 65
br i1 %18, label %19, label %30
19: ; preds = %14
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp sle i32 %22, 90
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 65
%29 = add nsw i32 %28, 97
br label %34
30: ; preds = %19, %14
%31 = load i8*, i8** %6
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
br label %34
34: ; preds = %30, %24
%35 = phi i32 [ %29, %24 ], [ %33, %30 ]
%36 = load i8, i8* %9
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %35, %37
br i1 %38, label %39, label %47
39: ; preds = %34
%40 = load i8*, i8** %6
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %6
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i64 0
store i8 0, i8* %43
%44 = load i8*, i8** %8
%45 = load i8*, i8** %6
%46 = call i32 @strcpy(i8* %44, i8* %45)
store i32 1, i32* %5
br label %80
47: ; preds = %34
%48 = load i8, i8* %9
%49 = call i8* @iStrDupUntilNoCase(i8** %6, i8 signext %48)
store i8* %49, i8** %10
%50 = load i8*, i8** %10
%51 = icmp ne i8* %50, null
br i1 %51, label %58, label %52
52: ; preds = %47
%53 = load i8*, i8** %7
%54 = load i8*, i8** %6
%55 = call i32 @strcpy(i8* %53, i8* %54)
%56 = load i8*, i8** %8
%57 = getelementptr inbounds i8, i8* %56, i64 0
store i8 0, i8* %57
store i32 1, i32* %5
br label %80
58: ; preds = %47
%59 = load i8*, i8** %6
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %71
63: ; preds = %58
%64 = load i8*, i8** %7
%65 = load i8*, i8** %10
%66 = call i32 @strcpy(i8* %64, i8* %65)
%67 = load i8*, i8** %10
%68 = call i32 @free(i8* %67)
%69 = load i8*, i8** %8
%70 = getelementptr inbounds i8, i8* %69, i64 0
store i8 0, i8* %70
store i32 1, i32* %5
br label %80
71: ; preds = %58
%72 = load i8*, i8** %7
%73 = load i8*, i8** %10
%74 = call i32 @strcpy(i8* %72, i8* %73)
%75 = load i8*, i8** %8
%76 = load i8*, i8** %6
%77 = call i32 @strcpy(i8* %75, i8* %76)
%78 = load i8*, i8** %10
%79 = call i32 @free(i8* %78)
store i32 2, i32* %5
br label %80
80: ; preds = %71, %63, %52, %39, %13
%81 = load i32, i32* %5
ret i32 %81
}

LLVM IR (-O2):
define i32 @iupStrToStrStr(i8* %0, i8* %1, i8* %2, i8 signext %3) {
%5 = alloca i8*
store i8* %0, i8** %5
%6 = icmp eq i8* %0, null
br i1 %6, label %35, label %7
7: ; preds = %4
%8 = load i8, i8* %0
%9 = sext i8 %8 to i32
%10 = add i8 %8, -65
%11 = icmp ult i8 %10, 26
%12 = add nsw i32 %9, 32
%13 = select i1 %11, i32 %12, i32 %9
%14 = sext i8 %3 to i32
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %7
%17 = getelementptr inbounds i8, i8* %0, i64 1
store i8* %17, i8** %5
store i8 0, i8* %1
%18 = tail call i32 @strcpy(i8* %2, i8* %17)
br label %35
19: ; preds = %7
%20 = call i8* @iStrDupUntilNoCase(i8** %5, i8 signext %3)
%21 = icmp eq i8* %20, null
%22 = load i8*, i8** %5
br i1 %21, label %23, label %25
23: ; preds = %19
%24 = call i32 @strcpy(i8* %1, i8* %22)
store i8 0, i8* %2
br label %35
25: ; preds = %19
%26 = load i8, i8* %22
%27 = icmp eq i8 %26, 0
%28 = call i32 @strcpy(i8* %1, i8* %20)
br i1 %27, label %29, label %31
29: ; preds = %25
%30 = call i32 @free(i8* %20)
store i8 0, i8* %2
br label %35
31: ; preds = %25
%32 = load i8*, i8** %5
%33 = call i32 @strcpy(i8* %2, i8* %32)
%34 = call i32 @free(i8* %20)
br label %35
35: ; preds = %23, %29, %31, %4, %16
%36 = phi i32 [ 1, %16 ], [ 0, %4 ], [ 1, %29 ], [ 2, %31 ], [ 1, %23 ]
ret i32 %36
}