#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*/ strcpy(char *, char *);
char *strstr(char *, char *);
int readOnOff(char *cmdResult) {
  char *jj, *gg;
  char ss[140];
  int nn;
  jj = strstr(cmdResult, "(");
  gg = strstr(cmdResult, ")");
  strcpy(ss, (jj + 1));
  ss[gg - jj - 1] = '\0';
  nn = atoi(ss);
  return (nn);
}


x86 assembly (clang, -O0):
<readOnOff>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
movb   $0x0,-0xb0(%rbp,%rax,1)
lea    -0xb0(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readOnOff>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %rdi,%r14
mov    $0x28,%esi
call   1040 <strchr@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x29,%esi
call   1040 <strchr@plt>
mov    %rax,%r14
lea    0x1(%rbx),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
not    %rbx
add    %r14,%rbx
movb   $0x0,(%rsp,%rbx,1)
mov    %r15,%rdi
call   1050 <atoi@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"(\00"
@.str.1 = [2 x i8] c")\00"
define i32 @readOnOff(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [140 x i8]
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i8* @strstr(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %3
%9 = load i8*, i8** %2
%10 = call i8* @strstr(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %10, i8** %4
%11 = getelementptr inbounds [140 x i8], [140 x i8]* %5, i64 0, i64 0
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = call i32 @strcpy(i8* %11, i8* %13)
%15 = load i8*, i8** %4
%16 = load i8*, i8** %3
%17 = ptrtoint i8* %15 to i64
%18 = ptrtoint i8* %16 to i64
%19 = sub i64 %17, %18
%20 = sub nsw i64 %19, 1
%21 = getelementptr inbounds [140 x i8], [140 x i8]* %5, i64 0, i64 %20
store i8 0, i8* %21
%22 = getelementptr inbounds [140 x i8], [140 x i8]* %5, i64 0, i64 0
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
ret i32 %24
}

LLVM IR (-O2):
define i32 @readOnOff(i8* %0) {
%2 = alloca [140 x i8]
%3 = getelementptr inbounds [140 x i8], [140 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 40)
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 41)
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = call i32 @strcpy(i8* %3, i8* %6)
%8 = ptrtoint i8* %5 to i64
%9 = ptrtoint i8* %4 to i64
%10 = xor i64 %9, -1
%11 = add i64 %8, %10
%12 = getelementptr inbounds [140 x i8], [140 x i8]* %2, i64 0, i64 %11
store i8 0, i8* %12
%13 = call i32 @atoi(i8* %3)
ret i32 %13
}