#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 */
long atol(char *);
char *strchr(char *, char);
int tl_readrat(long *num, long *den, char *str) {
  char *div = strchr(str, '/');
  if (div == NULL) {
    *num = atol(str);
    *den = 1;
  } else if (div == str || *(div + 1) == 0) {
    return 0L;
  } else {
    *div = 0;
    *num = atol(str);
    *den = atol(div + 1);
  }
  return 1L;
}


x86 assembly (clang, -O0):
<tl_readrat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1174 <tl_readrat+0x54>
mov    -0x20(%rbp),%rdi
call   1040 <atol@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x1,(%rax)
jmp    11d5 <tl_readrat+0xb5>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     1193 <tl_readrat+0x73>
mov    -0x28(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    119f <tl_readrat+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    11dc <tl_readrat+0xbc>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
call   1040 <atol@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   1040 <atol@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    11d5 <tl_readrat+0xb5>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tl_readrat>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     116f <tl_readrat+0x4f>
xor    %ecx,%ecx
cmp    %rbx,%rax
je     1187 <tl_readrat+0x67>
cmpb   $0x0,0x1(%rax)
je     1187 <tl_readrat+0x67>
mov    %rax,%r12
add    $0x1,%r12
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1040 <atol@plt>
mov    %rax,(%r15)
mov    %r12,%rdi
call   1040 <atol@plt>
jmp    117f <tl_readrat+0x5f>
mov    %rbx,%rdi
call   1040 <atol@plt>
mov    %rax,(%r15)
mov    $0x1,%eax
mov    %rax,(%r14)
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @tl_readrat(i64* %0, i64* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i8*
%8 = alloca i8*
store i64* %0, i64** %5
store i64* %1, i64** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %7
%10 = call i8* @strchr(i8* %9, i8 signext 47)
store i8* %10, i8** %8
%11 = load i8*, i8** %8
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i8*, i8** %7
%15 = call i64 @atol(i8* %14)
%16 = load i64*, i64** %5
store i64 %15, i64* %16
%17 = load i64*, i64** %6
store i64 1, i64* %17
br label %39
18: ; preds = %3
%19 = load i8*, i8** %8
%20 = load i8*, i8** %7
%21 = icmp eq i8* %19, %20
br i1 %21, label %28, label %22
22: ; preds = %18
%23 = load i8*, i8** %8
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %22, %18
store i32 0, i32* %4
br label %40
29: ; preds = %22
%30 = load i8*, i8** %8
store i8 0, i8* %30
%31 = load i8*, i8** %7
%32 = call i64 @atol(i8* %31)
%33 = load i64*, i64** %5
store i64 %32, i64* %33
%34 = load i8*, i8** %8
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = call i64 @atol(i8* %35)
%37 = load i64*, i64** %6
store i64 %36, i64* %37
br label %38
38: ; preds = %29
br label %39
39: ; preds = %38, %13
store i32 1, i32* %4
br label %40
40: ; preds = %39, %28
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
define i32 @tl_readrat(i64* nocapture writeonly %0, i64* nocapture writeonly %1, i8* %2) {
%4 = tail call i8* @strchr(i8* dereferenceable(1) %2, i8 signext 47)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i64 @atol(i8* %2)
store i64 %7, i64* %0
br label %17
8: ; preds = %3
%9 = icmp eq i8* %4, %2
br i1 %9, label %19, label %10
10: ; preds = %8
%11 = getelementptr inbounds i8, i8* %4, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %10
store i8 0, i8* %4
%15 = tail call i64 @atol(i8* %2)
store i64 %15, i64* %0
%16 = tail call i64 @atol(i8* %11)
br label %17
17: ; preds = %14, %6
%18 = phi i64 [ %16, %14 ], [ 1, %6 ]
store i64 %18, i64* %1
br label %19
19: ; preds = %8, %10, %17
%20 = phi i32 [ 1, %17 ], [ 0, %10 ], [ 0, %8 ]
ret i32 %20
}