#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 *);
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char *);
int formatModelIdentifier(char *unformattedModelID, char *formattedModelID) {
  int returnValue = 1;
  char delims[] = "\"=";
  char *token = NULL;
  int modelLabel = 0;
  token = strtok(unformattedModelID, delims);
  while (token != NULL) {
    if (strcmp(token, "model")) {
      if (modelLabel == 1) {
        strcat(formattedModelID, token);
        returnValue = 0;
        break;
      }
    } else {
      modelLabel = 1;
    }
    token = strtok(NULL, delims);
  }
  return returnValue;
}


x86 assembly (clang, -O0):
<formatModelIdentifier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    0xeb2(%rip),%ax
mov    %ax,-0x17(%rbp)
mov    0xeaa(%rip),%al
mov    %al,-0x15(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x17(%rbp),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11e5 <formatModelIdentifier+0xb5>
mov    -0x20(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11c8 <formatModelIdentifier+0x98>
cmpl   $0x1,-0x24(%rbp)
jne    11c3 <formatModelIdentifier+0x93>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcat@plt>
movl   $0x0,-0x14(%rbp)
jmp    11e5 <formatModelIdentifier+0xb5>
jmp    11cf <formatModelIdentifier+0x9f>
movl   $0x1,-0x24(%rbp)
lea    -0x17(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    117b <formatModelIdentifier+0x4b>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<formatModelIdentifier>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
movb   $0x0,0xe(%rsp)
movw   $0x3d22,0xc(%rsp)
lea    0xc(%rsp),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     11c5 <formatModelIdentifier+0x95>
mov    %rax,%rbx
mov    %rbp,0x10(%rsp)
xor    %ebp,%ebp
lea    0xe96(%rip),%r15
lea    0xc(%rsp),%r12
mov    $0x1,%r13d
jmp    1195 <formatModelIdentifier+0x65>
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r12,%rsi
call   1040 <strtok@plt>
mov    %rax,%rbx
mov    %r14d,%ebp
test   %rax,%rax
je     11cb <formatModelIdentifier+0x9b>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     1180 <formatModelIdentifier+0x50>
xor    %r14d,%r14d
cmp    $0x1,%ebp
jne    1180 <formatModelIdentifier+0x50>
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
xor    %r13d,%r13d
jmp    11cb <formatModelIdentifier+0x9b>
mov    $0x1,%r13d
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.formatModelIdentifier.delims = [3 x i8] c"\22=\00"
@.str = [6 x i8] c"model\00"
define i32 @formatModelIdentifier(i8* %0, i8* %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = call i8* @strtok(i8* %0, i8* %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %20, label %7
7: ; preds = %2, %16
%8 = phi i32 [ %17, %16 ], [ 0, %2 ]
%9 = phi i8* [ %18, %16 ], [ %5, %2 ]
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = icmp eq i32 %8, 1
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 @strcat(i8* %1, i8* %9)
br label %20
16: ; preds = %7, %12
%17 = phi i32 [ 0, %12 ], [ 1, %7 ]
%18 = call i8* @strtok(i8* null, i8* %4)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %7
20: ; preds = %16, %2, %14
%21 = phi i32 [ 0, %14 ], [ 1, %2 ], [ 1, %16 ]
ret i32 %21
}