#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 */
struct discriminant_t {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ disc_init(struct discriminant_t *);
int /*<<< orphan*/ discriminant_parse(char *, struct discriminant_t *);
int /*<<< orphan*/ free(char *);
char *strdup(char const *);
char *strtok(char *, char *);
void discriminantv_parse(const char *s, struct discriminant_t *disc) {
  char *_t = strdup(s);
  char *_disc = NULL;
  disc_init(disc);
  while ((_disc = strtok(_disc ? NULL : _t, ",")))
    discriminant_parse(_disc, disc);
  free(_t);
}


x86 assembly (clang, -O0):
<discriminantv_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <disc_init@plt>
cmpq   $0x0,-0x20(%rbp)
je     1194 <discriminantv_parse+0x44>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    119c <discriminantv_parse+0x4c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11cc <discriminantv_parse+0x7c>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <discriminant_parse@plt>
jmp    117e <discriminantv_parse+0x2e>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<discriminantv_parse>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
call   1070 <strdup@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <disc_init@plt>
lea    0xe91(%rip),%rsi
mov    %r14,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     11aa <discriminantv_parse+0x5a>
lea    0xe7d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <discriminant_parse@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
jne    1190 <discriminantv_parse+0x40>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

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

LLVM IR (-O2):
%struct.discriminant_t = type { i32 }
@.str = [2 x i8] c",\00"
define void @discriminantv_parse(i8* nocapture %0, %struct.discriminant_t* %1) {
%3 = tail call i8* @strdup(i8* %0)
%4 = tail call i32 @disc_init(%struct.discriminant_t* %1)
%5 = tail call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %2, %7
%8 = phi i8* [ %10, %7 ], [ %5, %2 ]
%9 = tail call i32 @discriminant_parse(i8* %8, %struct.discriminant_t* %1)
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %7
12: ; preds = %7, %2
%13 = tail call i32 @free(i8* %3)
ret void
}