#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 atoi(char *);
int /*<<< orphan*/ ofree(char *);
char *ostrdup(char *);
char *strtok(char *, char *);
int get_ydim(char *str) {
  int ret = 0;
  char *dup;
  char *tok;
  dup = ostrdup(str);
  strtok(dup, " ");
  strtok(NULL, " ");
  strtok(NULL, " ");
  tok = strtok(NULL, " ");
  if (tok != NULL) {
    ret = atoi(tok);
  }
  ofree(dup);
  return (ret);
}


x86 assembly (clang, -O0):
<get_ydim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ostrdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1050 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe85(%rip),%rsi
call   1050 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe75(%rip),%rsi
call   1050 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe65(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11bb <get_ydim+0x7b>
mov    -0x20(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ofree@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ydim>:
push   %r15
push   %r14
push   %rbx
call   1030 <ostrdup@plt>
mov    %rax,%r14
lea    0xeac(%rip),%rbx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <strtok@plt>
xor    %r15d,%r15d
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     1190 <get_ydim+0x50>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1040 <ofree@plt>
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i32 @get_ydim(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%6 = load i8*, i8** %2
%7 = call i8* @ostrdup(i8* %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = load i8*, i8** %5
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %3
br label %18
18: ; preds = %15, %1
%19 = load i8*, i8** %4
%20 = call i32 @ofree(i8* %19)
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i32 @get_ydim(i8* %0) {
%2 = tail call i8* @ostrdup(i8* %0)
%3 = tail call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i32 @atoi(i8* %6)
br label %10
10: ; preds = %8, %1
%11 = phi i32 [ %9, %8 ], [ 0, %1 ]
%12 = tail call i32 @ofree(i8* %2)
ret i32 %11
}