#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 */
typedef int /*<<< orphan*/ token;

/* Variables and functions */
scalar_t__ convert_str_to_number(unsigned char *);
unsigned char *find_next_token(unsigned char *, unsigned char *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
unsigned char *camsensor_parser_find_addr(unsigned char *fpage,
                                          unsigned short *address) {
  unsigned char *cur_ptr;
  unsigned char token[20];
  memset(token, 0, sizeof(token));
  cur_ptr = find_next_token(fpage, token);
  if (cur_ptr) {
    *address = (unsigned short)convert_str_to_number(token);
  }
  return cur_ptr;
}


x86 assembly (clang, -O0):
<camsensor_parser_find_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <find_next_token@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117f <camsensor_parser_find_addr+0x4f>
lea    -0x30(%rbp),%rdi
call   1040 <convert_str_to_number@plt>
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<camsensor_parser_find_addr>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <find_next_token@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1170 <camsensor_parser_find_addr+0x40>
mov    %rsp,%rdi
call   1040 <convert_str_to_number@plt>
mov    %ax,(%r14)
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @camsensor_parser_find_addr(i8* %0, i16* %1) {
%3 = alloca i8*
%4 = alloca i16*
%5 = alloca i8*
%6 = alloca [20 x i8]
store i8* %0, i8** %3
store i16* %1, i16** %4
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 20)
%9 = load i8*, i8** %3
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%11 = call i8* @find_next_token(i8* %9, i8* %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%16 = call i64 @convert_str_to_number(i8* %15)
%17 = trunc i64 %16 to i16
%18 = load i16*, i16** %4
store i16 %17, i16* %18
br label %19
19: ; preds = %14, %2
%20 = load i8*, i8** %5
ret i8* %20
}

LLVM IR (-O2):
define i8* @camsensor_parser_find_addr(i8* %0, i16* nocapture writeonly %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 20)
%6 = call i8* @find_next_token(i8* %0, i8* %4)
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = call i64 @convert_str_to_number(i8* %4)
%10 = trunc i64 %9 to i16
store i16 %10, i16* %1
br label %11
11: ; preds = %8, %2
ret i8* %6
}