#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*/ free(char *);
char *malloc(scalar_t__);
scalar_t__ strlen(char const *);
char *strncpy(char *, char const *, scalar_t__);
char *strtok(char *, char *);
void parse_block_dims(const char *arg, int *r, int *c) {
  char *dims = malloc(strlen(arg) + 1);
  dims = strncpy(dims, arg, strlen(arg) + 1);
  char *r_str = strtok(dims, "x");
  char *c_str = strtok(NULL, "x");
  *r = atoi(r_str);
  *c = atoi(c_str);
  free(dims);
}


x86 assembly (clang, -O0):
<parse_block_dims>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1040 <strncpy@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe23(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_block_dims>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
call   1050 <strlen@plt>
lea    0x1(%rax),%rbx
mov    %rbx,%rdi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1040 <strncpy@plt>
lea    0xe63(%rip),%r13
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <strtok@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %r13,%rsi
call   1070 <strtok@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1080 <atoi@plt>
mov    %eax,(%r15)
mov    %rbx,%rdi
call   1080 <atoi@plt>
mov    %eax,(%r14)
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"x\00"
define void @parse_block_dims(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%10 = load i8*, i8** %4
%11 = call i64 @strlen(i8* %10)
%12 = add nsw i64 %11, 1
%13 = call i8* @malloc(i64 %12)
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = load i8*, i8** %4
%16 = load i8*, i8** %4
%17 = call i64 @strlen(i8* %16)
%18 = add nsw i64 %17, 1
%19 = call i8* @strncpy(i8* %14, i8* %15, i64 %18)
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = call i8* @strtok(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %8
%22 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %9
%23 = load i8*, i8** %8
%24 = call i32 @atoi(i8* %23)
%25 = load i32*, i32** %5
store i32 %24, i32* %25
%26 = load i8*, i8** %9
%27 = call i32 @atoi(i8* %26)
%28 = load i32*, i32** %6
store i32 %27, i32* %28
%29 = load i8*, i8** %7
%30 = call i32 @free(i8* %29)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"x\00"
define void @parse_block_dims(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = add nsw i64 %4, 1
%6 = tail call i8* @malloc(i64 %5)
%7 = tail call i8* @strncpy(i8* dereferenceable(1) %6, i8* %0, i64 %5)
%8 = tail call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @atoi(i8* %8)
store i32 %10, i32* %1
%11 = tail call i32 @atoi(i8* %9)
store i32 %11, i32* %2
%12 = tail call i32 @free(i8* %6)
ret void
}