#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 scalar_t__ int8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stdin;
scalar_t__ uexpect(int /*<<< orphan*/, char *, char *, int /*<<< orphan*/ *);
int8_t esp8266_network(char *ssid, char *passwd) {
  int8_t retval;
  printf("AT+CWJAP=\"%s\",\"%s\"\r\n", ssid, passwd);
  retval = uexpect(stdin, "\r\nOK\r\n", "\r\nFAIL\r\n", NULL);
  if (retval != 0)
    return retval;
  return 0;
}


x86 assembly (clang, -O0):
<esp8266_network>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
lea    0xec1(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <uexpect@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1180 <esp8266_network+0x60>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1188 <esp8266_network+0x68>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<esp8266_network>:
push   %rax
mov    %rsi,%rdx
mov    %rdi,%rsi
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
lea    0xed2(%rip),%rsi
lea    0xed2(%rip),%rdx
xor    %ecx,%ecx
pop    %rax
jmp    1040 <uexpect@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"AT+CWJAP=\22%s\22,\22%s\22\0D\0A\00"
@stdin = global i32 0
@.str.1 = [7 x i8] c"\0D\0AOK\0D\0A\00"
@.str.2 = [9 x i8] c"\0D\0AFAIL\0D\0A\00"
define i64 @esp8266_network(i8* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
%10 = load i32, i32* @stdin
%11 = call i64 @uexpect(i32 %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* null)
store i64 %11, i64* %6
%12 = load i64, i64* %6
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = load i64, i64* %6
store i64 %15, i64* %3
br label %17
16: ; preds = %2
store i64 0, i64* %3
br label %17
17: ; preds = %16, %14
%18 = load i64, i64* %3
ret i64 %18
}

LLVM IR (-O2):
@.str = [21 x i8] c"AT+CWJAP=\22%s\22,\22%s\22\0D\0A\00"
@stdin = global i32 0
@.str.1 = [7 x i8] c"\0D\0AOK\0D\0A\00"
@.str.2 = [9 x i8] c"\0D\0AFAIL\0D\0A\00"
define i64 @esp8266_network(i8* %0, i8* %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%4 = load i32, i32* @stdin
%5 = tail call i64 @uexpect(i32 %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* null)
ret i64 %5
}