#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_array(char **, int);
int /*<<< orphan*/ strcpy(char *, char *);
char **strtoken(char *, char *, int *);
int /*<<< orphan*/ trim(char *);
int cmd_set_ps1(char *command, char **ps1) {
  int token_len = 0;
  char **tokens;
  trim(command);
  tokens = strtoken(command, "\"", &token_len);
  if (token_len != 2)
    return 0;
  strcpy(ps1[0], tokens[1]);
  free_array(tokens, token_len);
  return 1;
}


x86 assembly (clang, -O0):
<cmd_set_ps1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <trim@plt>
mov    -0x10(%rbp),%rdi
lea    0xe95(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <strtoken@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x2,-0x1c(%rbp)
je     118e <cmd_set_ps1+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <cmd_set_ps1+0x75>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <free_array@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_set_ps1>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0x4(%rsp)
call   1040 <trim@plt>
lea    0xea2(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <strtoken@plt>
mov    %rax,%rbx
xor    %eax,%eax
cmpl   $0x2,0x4(%rsp)
jne    1194 <cmd_set_ps1+0x54>
mov    (%r14),%rdi
mov    0x8(%rbx),%rsi
call   1030 <strcpy@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1050 <free_array@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\22\00"
define i32 @cmd_set_ps1(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i8*, i8** %4
%9 = call i32 @trim(i8* %8)
%10 = load i8*, i8** %4
%11 = call i8** @strtoken(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32* %6)
store i8** %11, i8*** %7
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 0, i32* %3
br label %26
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = load i8**, i8*** %7
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %18, i8* %21)
%23 = load i8**, i8*** %7
%24 = load i32, i32* %6
%25 = call i32 @free_array(i8** %23, i32 %24)
store i32 1, i32* %3
br label %26
26: ; preds = %15, %14
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [2 x i8] c"\22\00"
define i32 @cmd_set_ps1(i8* %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 @trim(i8* %0)
%6 = call i8** @strtoken(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = getelementptr inbounds i8*, i8** %6, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strcpy(i8* %10, i8* %12)
%14 = load i32, i32* %3
%15 = call i32 @free_array(i8** %6, i32 %14)
br label %16
16: ; preds = %2, %9
%17 = phi i32 [ 1, %9 ], [ 0, %2 ]
ret i32 %17
}